示例#1
0
 public ActionResult Settings()
 {
     ProfileSettingsModel model = new ProfileSettingsModel();
     var db = MaintDbContext;
     var user = db.Users.FirstOrDefault(x => x.LoginName == User.Identity.Name);
     model.SetInnerObject(user);
     return Template(model.CreateTemplate(ControllerContext));
 }
示例#2
0
 public async Task<ActionResult> Settings(ProfileSettingsModel model)
 {
     if (!ModelState.IsValid)
     {
         return Template(model.CreateTemplate(ControllerContext));
     }
     var db = MaintDbContext;
     var user = db.Users.FirstOrDefault(x => x.LoginName == User.Identity.Name && x.IsEnabled);
     if (user == null)
     {
         return HttpNotFound();
     }
     user.CultureId = model.Culture ?? 0;
     user.DateOfBirth = model.DateOfBirth;
     user.Gender = model.Gender;
     user.UserName = model.UserName;
     await db.SaveChangesAsync();
     await SetFlashAsync(new FlashMessage
     {
         Text = MaintCultureTextResources.SuccessToSave,
         MessageType = FlashMessageType.Success,
     });
     return Template(model.CreateTemplate(ControllerContext));
 }