コード例 #1
0
        public ActionResult Create(CreateEmployeeVacationModel model)
        {
            try
            {
                model.IsAdmin = (SessionData.UserRole == UserRoles.Admin);
                EmployeeVacationsLogic.CreateEmployeeVacationRequest(model);
                if (!model.Succeeded)
                {
                    ModelState.AddModelError("ErrorMessage", model.ErrorMessage);
                    return(PartialView("CreatePartial", model));
                }
                string url = model.IsAdmin? "/Users/DeveloperIndex" : "/Employees/Index";
                return(PartialView("JavascriptRedirect", new JavascriptRedirectModel(url)));
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagementProject/EmployeeVacations/Create(Post)",
                    Parameters = new JavaScriptSerializer().Serialize(model)
                });
            }

            return(PartialView("CreatePartial", model));
        }
コード例 #2
0
        public ActionResult Create(int userId = 0)
        {
            CreateEmployeeVacationModel model;

            try
            {
                if (userId == 0)
                {
                    userId = SessionData.UserId;
                }
                model = EmployeeVacationsLogic.CreateEmployeeVacationRequest(userId);
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagementProject/EmployeeVacations/Create(Get)",
                });
                model = new CreateEmployeeVacationModel()
                {
                    EmployeeVacation = new EmployeeVacation(), VacationTypesList = new List <VacationType>()
                };
            }
            return(PartialView("CreatePartial", model));
        }