public ActionResult Create(BusyDayCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBusyDayService();

            service.CreateBusyDay(model);

            return(RedirectToAction("Index", "Calendar"));
        }
示例#2
0
        public bool CreateBusyDay(BusyDayCreate model)
        {
            if (model.BusyEnd == null || model.BusyEnd < model.Busy)
            {
                model.BusyEnd = model.Busy;
            }
            var entity =
                new BusyDay()
            {
                UserID      = _userID,
                Busy        = model.Busy,
                BusyEnd     = (DateTimeOffset)model.BusyEnd,
                Description = model.Description
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.BusyDays.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }