Esempio n. 1
0
        public ActionResult Create(TaskViewModel TVM, int idProject)
        {
            if (!Request.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            //redirect to nowhere if not admin
            if (!(User.IsInRole("Team Leader")))
            {
                return(RedirectToAction("Nowhere", "Account"));
            }
            Tasks   T = new Tasks();
            Project P = PS.GetById(idProject);

            if (TVM.Start_Date >= P.Start_Date && TVM.End_Date <= P.End_Date && TVM.Start_Date >= DateTime.Now.Date)
            {
                T.TasksId     = TVM.TasksId;
                T.TaskName    = TVM.TaskName;
                T.Start_Date  = TVM.Start_Date;
                T.End_Date    = TVM.End_Date;
                T.Duration    = (TVM.End_Date - TVM.Start_Date).TotalDays.ToString();
                T.Status      = Domain.Entities.status.Not;
                T.Description = TVM.Description;
                T.ProjectFK   = idProject;

                TS.Add(T);
                TS.Commit();
                return(RedirectToAction("Details", "Project", new { id = idProject }));
            }
            else
            {
                ViewBag.Message = "Tasks dates must be between " + P.Start_Date.ToString("dd/MM/yyyy") + " and " + P.End_Date.ToString("dd/MM/yyyy") + " and Start Date greater tha Today !!!";
                return(View("Create"));
            }
        }
Esempio n. 2
0
        public ActionResult Post([FromBody] TaskViewModel vm)
        {
            try
            {
                var dto = _taskServices.Add(_mapper.Map <TaskViewModel, TaskDto>(vm));

                return(Ok(TasksResult(dto)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Esempio n. 3
0
        public ActionResult Create(TaskViewModel TVM, int idProject)
        {
            Tasks T = new Tasks();

            T.TasksId     = TVM.TasksId;
            T.TaskName    = TVM.TaskName;
            T.Start_Date  = TVM.Start_Date;
            T.End_Date    = TVM.End_Date;
            T.Estimation  = TVM.Estimation;
            T.Status      = Domain.Entities.status.Done;
            T.Description = TVM.Description;
            T.Duration    = TVM.Duration;
            T.ProjectFK   = idProject;

            TS.Add(T);
            TS.Commit();
            return(RedirectToAction("Details", "Project", new { id = idProject }));
        }