no

no
mail@pastecode.io avatar
unknown
csharp
2 years ago
1.6 kB
2
Indexable
Never
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NETFarm.Models.Article;
using NETFarm.Models.ChangePass;
using NETFarm.Services.ArticleServices;
using NETFarm.Services.ChangePassServices;

namespace NETFarm.Controllers.SMS_controller
{
    [Route("api/[controller]")]
    [ApiController]
    [DisableCors]
    public class ChangePassController : ControllerBase
    {
        private readonly IChangePass _changePass ;

        public ChangePassController(IChangePass changePass)
        {
            _changePass = changePass;
        }
        [HttpPut("{id}")]
        //   [Authorize(Roles = "Admin, Expert")]
        public IActionResult UpdatePass(int id, ChangePassModel changePass)
        {
            try
            {
                var result = _changePass.changePass(id,changePass);
                return Ok(result);
            }
            catch
            {
                return StatusCode(StatusCodes.Status500InternalServerError);
            }
        }
        [HttpGet("{phone}")]
        public IActionResult SendCode(string phone)
        {
            try
            {
                var data = _changePass.sendCode(phone);
                if (data != null)
                    return Ok(data);
                else
                    return NotFound();
            }
            catch
            {
                return StatusCode(StatusCodes.Status500InternalServerError);
            }
        }
    }
}