Esempio n. 1
0
 public IActionResult CreateByProject(TaskModel taskModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             TaskBLO taskBLO = new TaskBLO();
             taskBLO = taskConverter.Convert(taskModel);
             taskService.Insert(taskBLO);
             return(RedirectToAction("Edit", "Project", taskModel.ProjectId));
         }
         else
         {
             return(RedirectToAction("Create"));
         }
     }
     catch (Exception ex)
     {
         logger.LogError("Не удалось внести информацию о задаче");
         ErrorViewModel error = new ErrorViewModel()
         {
             source     = ex.Source,
             message    = ex.Message,
             stackTrace = ex.StackTrace
         };
         return(RedirectToAction("Error", "Home", error));
     }
 }
Esempio n. 2
0
 public IActionResult Edit(int id, TaskModel taskModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             TaskBLO taskBLO = new TaskBLO();
             taskBLO = taskConverter.Convert(taskModel);
             taskService.Update(taskBLO);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Edit"));
         }
     }
     catch (Exception ex)
     {
         logger.LogError("Не удалось изменить информацию о задаче");
         ErrorViewModel error = new ErrorViewModel()
         {
             source     = ex.Source,
             message    = ex.Message,
             stackTrace = ex.StackTrace
         };
         return(RedirectToAction("Error", "Home", error));
     }
 }
Esempio n. 3
0
 public IActionResult Create(TaskModel taskModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             TaskBLO taskBLO = new TaskBLO();
             taskBLO = taskConverter.Convert(taskModel);
             taskService.Insert(taskBLO);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Create"));
         }
     }
     catch (Exception ex)
     {
         logger.LogError("Не удалось создать задачу");
         ErrorViewModel error = new ErrorViewModel()
         {
             source     = ex.Source,
             message    = ex.Message,
             stackTrace = ex.StackTrace
         };
         return(RedirectToAction("Error", "Home", error));
     }
 }
Esempio n. 4
0
        private IList <TaskBLO> Convert(IList <TaskDTO> listDTO)
        {
            if (listDTO == null)
            {
                logger.LogError("Значение не может быть null");
                throw new ArgumentNullException(nameof(listDTO));
            }
            List <TaskBLO> tasks = new List <TaskBLO>();

            foreach (TaskDTO taskDTO in listDTO)
            {
                TaskBLO taskBLO = new TaskBLO()
                {
                    Id         = taskDTO.Id,
                    ProjectId  = taskDTO.ProjectId,
                    Name       = taskDTO.Name,
                    Timing     = taskDTO.Timing,
                    DateStart  = taskDTO.DateStart,
                    DateEnd    = taskDTO.DateEnd,
                    StatusId   = taskDTO.StatusId,
                    EmployeeId = taskDTO.EmployeeId,
                    Employee   = new EmployeeBLO()
                    {
                        Id         = taskDTO.Employee.Id,
                        Name       = taskDTO.Employee.Name,
                        Surname    = taskDTO.Employee.Surname,
                        Patronymic = taskDTO.Employee.Patronymic,
                        PositionId = taskDTO.Employee.PositionId,
                        Position   = new PositionBLO()
                        {
                            Id   = taskDTO.Employee.Position.Id,
                            Name = taskDTO.Employee.Position.Name
                        }
                    },
                    Status = new StatusBLO()
                    {
                        Id   = taskDTO.Status.Id,
                        Name = taskDTO.Status.Name
                    }
                };
                tasks.Add(taskBLO);
            }
            return(tasks);
        }