示例#1
0
        public async Task <IActionResult> Create(AddGeneral addGeneral)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (addGeneral.OfficialDayOff < DateTime.Now)
                    {
                        ModelState.AddModelError(string.Empty, "Official Day off must be greater than actual day");
                        return(View(addGeneral));
                    }
                    GeneralTable generalTable = new GeneralTable()
                    {
                        OfficialDayOff = addGeneral.OfficialDayOff,
                        Reason         = addGeneral.Reason
                    };
                    await _generalService.CreateGeneralAsync(generalTable);

                    return(RedirectToAction("CalendarHolidays"));
                }
                return(View(addGeneral));
            }
            catch (Exception)
            {
                ViewBag.Error = "Something wrong";
                return(View("Error"));
            }
        }