Ejemplo n.º 1
0
        public ActionResult ScheduleJob(AddJobViewModel model)
        {
            string userId = User.Identity.GetUserId();

            //Construct date time to send to logic
            DateTime startDateTime = new DateTime(
                int.Parse(model.JobData.Year),
                int.Parse(model.JobData.Month),
                int.Parse(model.JobData.Day),
                int.Parse(model.JobData.Hour),
                int.Parse(model.JobData.Minute),
                0
                );

            //Send new data to logic layer
            LogicService cmLogic          = new LogicService();
            bool         addedSucessfully = cmLogic.ScheduleJob(
                startDateTime,
                int.Parse(model.JobData.Duration),
                model.JobData.Notes,
                userId,
                model.JobOptions.SelectedClient,
                model.JobOptions.SelectedServiceType);

            //Redirect back to dashbaord, print results to screen
            if (addedSucessfully)
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 0, message = "Job Added Successfully" }));
            }
            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Add Job" }));
            }
        }