public void DeleteDepartmentNumber(int id) { DepartmentNumber departmentNumber = DB.DepartmentNumbers.Get(id); if (departmentNumber == null) { throw new ValidationException("Cлужебный номер не найден!", ""); } else { DB.DepartmentNumbers.Delete(id); DB.Save(); } }
public DepartmentNumberDTO GetDepartmentNumber(int id) { DepartmentNumber departmentNumber = DB.DepartmentNumbers.Get(id); if (departmentNumber == null) { return(null); } return(new DepartmentNumberDTO { Id = departmentNumber.Id, StrucDivId = departmentNumber.StrucDivId, StrucDivNum = departmentNumber.StrucDivNum }); }
public void UpdateDepartmentNumber(DepartmentNumberDTO departmentNumberDTO) { DepartmentNumber departmentNumber = DB.DepartmentNumbers.Get(departmentNumberDTO.Id); if (departmentNumber == null) { throw new ValidationException("Cлужебный номер не найден!", ""); } else { departmentNumber.Id = departmentNumberDTO.Id; departmentNumber.StrucDivId = departmentNumberDTO.StrucDivId; departmentNumber.StrucDivNum = departmentNumberDTO.StrucDivNum; DB.DepartmentNumbers.Update(departmentNumber); DB.Save(); } }
public void CreateDepartmentNumber(DepartmentNumberDTO departmentNumberDTO) { DepartmentNumber departmentNumber = DB.DepartmentNumbers.Find(p => p.StrucDivNum == departmentNumberDTO.StrucDivNum).FirstOrDefault(); if (departmentNumber == null) { DB.DepartmentNumbers.Create(new DepartmentNumber { Id = departmentNumberDTO.Id, StrucDivId = departmentNumberDTO.StrucDivId, StrucDivNum = departmentNumberDTO.StrucDivNum }); DB.Save(); } else { throw new ValidationException("Такой служебный номер уже существует!", ""); } }