Exemplo n.º 1
0
        public bool CreateBottle(BottleCreate model)
        {
            var entity =
                new BottleFeeding()
            {
                ParentID = _userID,
                BabyID   = model.BabyID,
                Name     = model.Name,
                Time     = model.Time,
                Contents = model.Contents,
                Quantity = model.Quantity,
                Consumed = model.Consumed,
                Notes    = model.Notes
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Bottles.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public IActionResult AddBottleFeeding(AddBottleFeedingViewModel addBottleFeedingViewModel, int id)
        {
            if (ModelState.IsValid)
            {
                //var StudentID = addMealViewModel.StudentID;
                Student student = context.Students.Single(s => s.ID == id);

                BottleFeeding newBottleFeeding = new BottleFeeding
                {
                    StudentID = student.ID,
                    Date      = addBottleFeedingViewModel.Date,
                    Ounce     = addBottleFeedingViewModel.Ounce
                };

                context.BottleFeedings.Add(newBottleFeeding);
                context.SaveChanges();

                return(Redirect(string.Format("/Form/InfantForm/{0}", student.ID)));
            }

            return(View(addBottleFeedingViewModel));
        }