public IActionResult UpdatePassword(string username, [FromBody] User item) { if (item == null || item.Username != username) { return(BadRequest()); } var ec = UserPasswordProfile.Encrypt(item.Password); var dc = UserPasswordProfile.Decrypt(ec); User found = _items.Find(i => i.Username == username); if (found == null) { return(NotFound()); } found.Password = UserPasswordProfile.Encrypt(item.Password); _items.Commit(); var newitem = from a in _items.AllIncluding(i => i.RoleuserNavigation) where a.Username == item.Username select new { a.Username, a.Fullname, roleuserName = a.RoleuserNavigation.Name }; return(CreatedAtRoute("GetUser", new { Controller = "User", id = item.Username }, newitem)); }
public IActionResult GetById(string id) { var item = from a in _items.AllIncluding(i => i.RoleuserNavigation, i => i.Userposition) where a.Username.ToLower() == id.ToLower() select new { a.Username, a.Fullname, Password = UserPasswordProfile.Decrypt(a.Password), passwordConfirm = UserPasswordProfile.Decrypt(a.Password), a.Roleuser, RoleuserName = a.RoleuserNavigation.Name }; if (item == null) { return(NotFound()); } return(new OkObjectResult(item)); }