public void UpdateTechnologiesForTask(List <int> technologyIDs, int taskID) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryTechnologyTaskUpdateColumn(technologyIDs, taskID); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } bool isTaskExist = IsTaskExist(taskID); if (!isTaskExist) { throw new Exception(CMResources.TaskIDNotExist); } List <TaskTechnology> taskTechnologies = (from taskTechnology in dataContext.TaskTechnologies where taskTechnology.TaskId == taskID select taskTechnology).ToList(); dataContext.TaskTechnologies.DeleteAllOnSubmit(taskTechnologies); dataContext.SubmitChanges(); foreach (int technologyID in technologyIDs) { bool isTechnologyExist = IsTechnologyExist(technologyID); if (!isTechnologyExist) { throw new Exception(CMResources.TechnologyIDNotExist); } } foreach (int technologyID in technologyIDs) { TaskTechnology taskTechnology = new TaskTechnology(); taskTechnology.TaskId = taskID; taskTechnology.TechnologyId = technologyID; dataContext.TaskTechnologies.InsertOnSubmit(taskTechnology); dataContext.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public void AddEmployee(Employee employee) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryEmployeeColumn(employee); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } dataContext.Employees.InsertOnSubmit(employee); dataContext.SubmitChanges(); } catch (Exception ex) { throw ex; } }
public void AddTechnology(TechnologyMaster technology) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryTechnologyColumn(technology); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } dataContext.TechnologyMasters.InsertOnSubmit(technology); dataContext.SubmitChanges(); } catch (Exception ex) { throw ex; } }
public void AddProject(Project project) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryProjectColumn(project); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } dataContext.Projects.InsertOnSubmit(project); dataContext.SubmitChanges(); } catch (Exception ex) { throw ex; } }
public void AssignTechnologyToTask(int technologyID, int taskID) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryTechnologyTaskColumn(technologyID, taskID); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } bool isTechnologyExist = IsTechnologyExist(technologyID); if (!isTechnologyExist) { throw new Exception(CMResources.TechnologyIDNotExist); } bool isTaskExist = IsTaskExist(taskID); if (!isTaskExist) { throw new Exception(CMResources.TaskIDNotExist); } bool isTechnologyTaskExist = IsTechnologyTaskExist(technologyID, taskID); if (isTechnologyTaskExist) { throw new Exception(CMResources.TechnologyAlreadyExistTask); } TaskTechnology taskTechnology = new TaskTechnology(); taskTechnology.TaskId = taskID; taskTechnology.TechnologyId = technologyID; dataContext.TaskTechnologies.InsertOnSubmit(taskTechnology); dataContext.SubmitChanges(); } catch (Exception ex) { throw ex; } }
public void AssignEmployeeToProject(int employeeID, int projectID) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryEmployeeProjectColumn(employeeID, projectID); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } bool isEmployeeExist = IsEmployeeExist(employeeID); if (!isEmployeeExist) { throw new Exception(CMResources.EmployeeIDNotExist); } bool isProjectExist = IsProjectExist(projectID); if (!isProjectExist) { throw new Exception(CMResources.ProjectIDNotExist); } bool isEmployeeProjectExist = IsEmployeeProjectExist(projectID, employeeID); if (isEmployeeProjectExist) { throw new Exception(CMResources.EmployeeAlreadyExistProject); } EmployeeProject employeeProject = new EmployeeProject(); employeeProject.EmployeeId = employeeID; employeeProject.ProjectId = projectID; dataContext.EmployeeProjects.InsertOnSubmit(employeeProject); dataContext.SubmitChanges(); } catch (Exception ex) { throw ex; } }