public virtual async Task <ActionResult> MyProfile(ProfileViewModel model) { if (ModelState.IsValid) { var user = new RaceDay.Services.Models.JsonUser { UserId = model.UserId, Name = model.Name.Trim(), FirstName = model.FirstName.Trim(), LastName = model.LastName.Trim(), Email = model.Email.Trim() }; var status = await RaceDayClient.EditUser(model.UserId, user); if (status == HttpStatusCode.OK) { if (model.Password != null && !string.IsNullOrEmpty(model.Password.Trim())) { status = await RaceDayClient.UpdatePassword(model.Email, model.Password); if (status == HttpStatusCode.OK) { model.PageMessage = new PageMessageModel(MessageDismissEnum.close, CssMessageClassEnum.success, "Profile with password updated"); } else { model.PageMessage = new PageMessageModel(MessageDismissEnum.close, CssMessageClassEnum.error, "Unable to update password"); } } else { model.PageMessage = new PageMessageModel(MessageDismissEnum.close, CssMessageClassEnum.success, "Profile updated"); } RaceDayUser.CurrentUser.Name = model.Name; RaceDayUser.CurrentUser.FirstName = model.FirstName; RaceDayUser.CurrentUser.LastName = model.LastName; RaceDayUser.CurrentUser.Email = model.Email; } else { model.PageMessage = new PageMessageModel(MessageDismissEnum.close, CssMessageClassEnum.error, "Unable to update profile"); } } return(View(model)); }
public virtual async Task <ActionResult> Edit(string id, [Bind(Include = "UserId,Name,FirstName,LastName,Email,Password")] MFUserViewModel mFUser) { if (ModelState.IsValid) { var user = await RaceDayClient.GetUserDetail(id); if (user != null) { user.Name = mFUser.Name; user.FirstName = mFUser.FirstName; user.LastName = mFUser.LastName; user.Email = mFUser.Email; user.Password = mFUser.Password; await RaceDayClient.EditUser(id, user); return(RedirectToAction("Index")); } } return(View(mFUser)); }