Пример #1
0
 public IActionResult Modify(ModifyCurrentUserModel model)
 {
     if (!AuthorizeService.AuthorizeUser(User, model.Id))
     {
         return(RedirectToAction("AccessDenied", "Auth"));
     }
     else
     {
         if (ModelState.IsValid)
         {
             User     user     = ModelConverter.ConvertFromUserModifyCurrnetUserModel(model);
             Response response = UserService.UpdateUser(user);
             if (response.IsSuccessful)
             {
                 return(RedirectToAction("Success"));
             }
             else
             {
                 ModelState.AddModelError(string.Empty, response.Message);
                 return(View(model));
             }
         }
         else
         {
             return(View(model));
         }
     }
 }
Пример #2
0
 public static User ConvertFromUserModifyCurrnetUserModel(ModifyCurrentUserModel currentUserModel)
 {
     return(new User
     {
         Id = currentUserModel.Id,
         UserName = currentUserModel.Username,
     });
 }
Пример #3
0
 public IActionResult Modify(int id)
 {
     if (!AuthorizeService.AuthorizeUser(User, id))
     {
         return(RedirectToAction("AccessDenied", "Auth"));
     }
     else
     {
         ModifyCurrentUserModel model = ModelConverter.ConvertToModifyCurrentUserModel(UserService.GetById(id));
         return(View(model));
     }
 }