using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using AIAHTML5.Server.Models; using System.Web.Http.Cors; using System.Web.Cors; using AIAHTML5.Server.Constants; using log4net; namespace AIAHTML5.Server.Controllers { [EnableCors(origins: "http://localhost:85", headers: "*", methods: "*")] public class ChangeUserPasswordController : ApiController { DbModel objDbModel = new DbModel(); // GET: api/ChangePassword public IEnumerable Get() { return new string[] { "value1", "value2" }; } // GET: api/ChangePassword/5 public HttpResponseMessage Get(string sLoginId, string sPassword) { string userDetails = objDbModel.GetUserDetailsByLoginIDandPassword(sLoginId, sPassword); var userJson = JsonConvert.SerializeObject(userDetails, Formatting.Indented); return Request.CreateResponse(HttpStatusCode.OK, userJson); } // POST: api/ChangePassword public string Post([FromBody]JObject userInfo) { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); int iUserId = Convert.ToInt32(userInfo["iUserId"]); string sPassword = userInfo["newPassword"].ToString(); int result = objDbModel.UpdateUserPassword(iUserId, sPassword); if (result > 0) return AdminConstant.SUCCESS; else return AdminConstant.FAILED; } // PUT: api/ChangePassword/5 public void Put(int id, [FromBody]string value) { } // DELETE: api/ChangePassword/5 public void Delete(int id) { } } }