示例#1
0
        public async Task <IActionResult> Create()
        {
            var model = new CreateCalenderViewModel {
                HoldList = await holdCRUD.GetHoldWithoutSchema()
            };

            return(View(model));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind] CreateCalenderViewModel model)
        {
            if (ModelState.IsValid)
            {
                var holdList = await holdCRUD.GetAllHold();

                await model.Calender.AddHold(model.SelectedIndicies, holdList);

                try
                {
                    await calenderCRUD.Create(model.Calender);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                    return(RedirectToAction(nameof(Create)));
                }
            }
            return(View());
        }