public IHttpActionResult Post(SystemPlanCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateSystemPlanService();

            if (!service.CreateSystemPlan(model))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Exemplo n.º 2
0
        public bool CreateSystemPlan(SystemPlanCreate plan)
        {
            var entity =
                new SystemPlan()
            {
                Id             = _userId,
                FitId          = plan.FitId,
                DietId         = plan.DietId,
                PlanGoal       = plan.PlanGoal,
                StartingWeight = plan.StartingWeight,
                CreatedUtc     = DateTimeOffset.Now,
                ModifiedUtc    = DateTime.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.SystemPlan.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 3
0
        public bool CreateSystemPlan(SystemPlanCreate plan)
        {
            var entity =
                new SystemPlan()
            {
                SysId     = plan.SysId,
                UserId    = _systemId,
                FitnessId = _systemId,
                DietId    = _systemId,
                //Name = plan.Name,
                StartingWeight = plan.StartingWeight,
                PlanGoal       = plan.PlanGoal,
                CreatedUtc     = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.SystemPlan.Add(entity);
                return(ctx.SaveChanges() > 0);
            }
        }