Example #1
0
        public bool OTCreate(OverTimeCreate model)
        {
            OverTime entity = new OverTime()
            {
                IsAvailable = false,
                OTDay       = model.OTDay,
                HoursWorked = model.HoursWorked,
                EmployeeId  = model.EmployeeId,
                Days        = model.Days
            };

            using (ApplicationDbContext ctx = new ApplicationDbContext())
            {
                ctx.OverTimeDays.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(OverTimeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //OverTimeServices service = new OverTimeServices();
            if (service.OTCreate(model))
            {
                TempData["SaveOTResult"] = $"OverTime {model.OTDay.ToLongDateString()} created.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Could not create OverTime date.");

            return(View(model));
        }