public IHttpActionResult UpdatePlan(SystemPlanEdit model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateSystemPlanService(); if (!service.UpdatePlan(model)) { return(InternalServerError()); } return(Ok()); }
public bool UpdatePlan(SystemPlanEdit plan) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .SystemPlan .Single(e => e.SysId == plan.SysId); //entity.Name = plan.Name; entity.StartingWeight = plan.StartingWeight; entity.PlanGoal = plan.PlanGoal; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() > 0); } }
public bool UpdatePlan(SystemPlanEdit plan) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .SystemPlan .SingleOrDefault(e => e.SysId == plan.SysId); if (entity != null) { entity.PlanGoal = plan.PlanGoal; entity.StartingWeight = plan.StartingWeight; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } else { return(false); } } }