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 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; } }