public IHttpActionResult UpdatePlan(AppUserEdit model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAppUserService(); if (!service.UpdatePlan(model)) { return(InternalServerError()); } return(Ok()); }
public async Task <ActionResult> Create(AppUserEdit model) { if (ModelState.IsValid) { var user = new AppUser { UserName = model.Name, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(RedirectToAction("Index")); } AddErrorsFromResult(result); } return(View(model)); }
public bool UpdatePlan(AppUserEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Users .SingleOrDefault(e => e.Id == _userId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Email = model.Email; entity.WeightInLbs = model.Weight; entity.HeightInCentimeters = model.Height; entity.DateOfBirth = (DateTime)model.DateOfBirth; entity.Gender = (Data.GenderEnum)model.Gender; entity.BodyType = (Data.BodyTypeEnum)model.BodyType; entity.Goal = (Data.GoalEnum)model.Goal; entity.DateJoined = DateTimeOffset.Now; return(ctx.SaveChanges() == 1); } }