コード例 #1
0
 //
 // GET: /Account/
 public ActionResult Index()
 {
     var user = _userService.GetUser((Guid)System.Web.Security.Membership.GetUser().ProviderUserKey);
     var userModel = new EditUserModel
     {
         ID = user.ID,
         Name = user.Name,
         Surname = user.Surname,
         BlogName = user.Blog.BlogName,
         BlogSubtitle = user.Blog.BlogSubtitle
     };
     return View(userModel);
 }
コード例 #2
0
 public ActionResult Index(EditUserModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             User userToUpdate = _userService.GetUser(model.ID);
             Blog blogToUpdate = _blogService.GetBlog(userToUpdate.Blog.ID);
             userToUpdate.Name = model.Name;
             userToUpdate.Surname = model.Surname;
             //userToUpdate.Userpic = ImageService.SaveImage(model.Image);
             blogToUpdate.BlogName = model.BlogName;
             blogToUpdate.BlogSubtitle = model.BlogSubtitle;
             _userService.EditUser(userToUpdate);
             _blogService.UpdateBlog(blogToUpdate);
             return RedirectToAction("Index", "Home");
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to edit user. Please correct the errors and try again.");
     }
     return View("Index");
 }
コード例 #3
0
 public ActionResult EditUser(Guid id)
 {
     var user = _userService.GetUser(id);
     var userModel = new EditUserModel
     {
         ID = user.ID,
         Name = user.Name,
         Surname = user.Surname,
         BlogName = user.Blog.BlogName,
         BlogSubtitle = user.Blog.BlogSubtitle
     };
     return View(userModel);
 }