public void AddParentTask(ParentTaskViewModel pTaskVM) { if (!IsParentTaskNameExist(pTaskVM.TaskName)) { var pTask = new ParentTask() { TaskName = pTaskVM.TaskName }; pTaskrepo.AddParentTask(pTask); } else { var customException = new CustomException(); customException.ExceptionMsg = "Parent task with same name is already exist in the system"; throw customException; } }
public void AddUser(UserViewModel user) { if (!IsEmployeeIdExist(user)) { var us = new User() { FirstName = user.FirstName, LastName = user.LastName, EmployeeId = user.EmployeeId }; userRepo.AddUser(us); } else { var customException = new CustomException(); customException.ExceptionMsg = "Employee Id is already exist in the system"; throw customException; } }
public void UpdateUser(UserViewModel user) { bool isAllowEdit = false; var us = userRepo.GetUserById(user.UserId); isAllowEdit = (us.EmployeeId == user.EmployeeId) ? true : !IsEmployeeIdExist(user); if (isAllowEdit) { us.FirstName = user.FirstName; us.LastName = user.LastName; us.EmployeeId = user.EmployeeId; userRepo.UpdateUser(us); } else { var customException = new CustomException(); customException.ExceptionMsg = "Employee Id is already exist in the system"; throw customException; } }
public void AddProject(ProjectViewModel pjVm) { if (!IsProjectNameExist(pjVm)) { var proj = new Project() { ProjectName = pjVm.ProjectName, StartDate = pjVm.StartDate, EndDate = pjVm.EndDate, Priority = pjVm.Priority, UserId = pjVm.UserId }; projRepo.AddProject(proj); } else { var customException = new CustomException(); customException.ExceptionMsg = "Same Project Name is already exist in the system"; throw customException; } }
public void UpdateProject(ProjectViewModel pjVm) { bool isAllowEdit = false; var prj = projRepo.GetProjectById(pjVm.ProjectId); isAllowEdit = (prj.ProjectName == pjVm.ProjectName) ? true : !IsProjectNameExist(pjVm); if (isAllowEdit) { prj.ProjectName = pjVm.ProjectName; prj.StartDate = pjVm.StartDate; prj.EndDate = pjVm.EndDate; prj.Priority = pjVm.Priority; prj.UserId = pjVm.UserId; projRepo.UpdateProject(prj); } else { var customException = new CustomException(); customException.ExceptionMsg = "Same Project Name is already exist in the system"; throw customException; } }
public void AddTask(TaskViewModel taskViewModel) { if (!IsTaskNameExist(taskViewModel)) { var task = new Task() { TaskName = taskViewModel.TaskName, StartDate = taskViewModel.StartDate, EndDate = taskViewModel.EndDate, ParentId = taskViewModel.ParentId, Priority = taskViewModel.Priority, UserId = taskViewModel.UserId, ProjectId = taskViewModel.ProjectId }; taskrepo.AddTask(task); } else { var customException = new CustomException(); customException.ExceptionMsg = "Task name is already exist in the system"; throw customException; } }