public IActionResult UpdateMultiPhase(ModifiedPhase modifiedPhase)
        {
            var currentUser = userService.GetCurrentUser(User.Identity.Name);


            foreach (var i in modifiedPhase.ListPhaseDelete)     // Xóa những phase có trong danh sách id xóa
            {
                var isPhaseExist = phaseService.CheckExist(x => x.PhaseId == i);
                if (isPhaseExist == true)
                {
                    phaseService.Delete(i);
                }
            }

            foreach (var i in modifiedPhase.ListFieldDelete)     // Xóa những field có trong danh sách id xóa
            {
                var isFieldExist = fieldService.CheckExist(x => x.FieldId == i);
                if (isFieldExist == true)
                {
                    fieldService.Delete(i);
                }
            }

            foreach (var i in modifiedPhase.ListEmployeeDelete)     // Xóa những employee có trong danh sách id xóa
            {
                var isFieldExist = phaseEmployeeService.CheckExist(x => x.PhaseEmployeeId == i);
                if (isFieldExist == true)
                {
                    phaseEmployeeService.Delete(i);
                }
            }

            foreach (var phase in modifiedPhase.Phase)
            {
                if (phase.PhaseId == null || phase.PhaseId.Equals(""))
                {
                    phase.PhaseId = Guid.NewGuid();
                }

                phaseService.AddOrUpdate(phase, currentUser);
            }
            var processUpdated = processService.GetById(modifiedPhase.ProcessId);

            processUpdated.UpdatedAt = DateTime.Now;
            processUpdated.UpdatedBy = currentUser.Employee.First().FullName + " - " + currentUser.Employee.First().EmployeeCode;


            phaseService.Save();

            return(Ok());
        }
        public IActionResult AddProcess(Process process)
        {
            User currentUser = userService.GetCurrentUser(User.Identity.Name);

            Category category = null;

            if (categoryService.Add(process.Category) != null) // them mới thành công
            {
                categoryService.Save();                        // Lưu lại trong database
            }


            category = categoryService.GetSingleByCondition(x => x.Name.ToUpper() == process.Category.Name.ToUpper());

            process.CategoryId = category.CategoryId;

            processService.Add(process, currentUser);
            processService.Save();

            phaseService.AddWhenCreateProcess(process.ProcessId, currentUser);
            phaseService.Save();

            return(Ok(process.ProcessId));
        }