コード例 #1
0
        public IActionResult Add(AddWalkViewModel addWalkViewModel)
        {
            if (ModelState.IsValid)
            {
                Walk newWalk = new Walk
                {
                    Distance = addWalkViewModel.Distance,
                    Poop     = addWalkViewModel.Poop,
                    Pee      = addWalkViewModel.Pee,
                    Date     = addWalkViewModel.Date,
                    Time     = addWalkViewModel.Time,
                    Notes    = addWalkViewModel.Notes,
                };

                context.Walks.Add(newWalk);
                context.SaveChanges();

                return(Redirect("/Walk"));
            }

            return(View(addWalkViewModel));
        }
コード例 #2
0
        public IActionResult Add()
        {
            AddWalkViewModel addWalkViewModel = new AddWalkViewModel();

            return(View(addWalkViewModel));
        }