public void UpdateDepartmentMobNumber(DepartmentMobNumberDTO departmentMobNumberDTO) { DepartmentMobNumber departmentMobNumber = DB.DepartmentMobNumbers.Get(departmentMobNumberDTO.Id); if (departmentMobNumber == null) { throw new ValidationException("Cлужебный моб. номер не найден!", ""); } else { departmentMobNumber.Id = departmentMobNumberDTO.Id; departmentMobNumber.StrucDivId = departmentMobNumberDTO.StrucDivId; departmentMobNumber.StrucDivMobNum = departmentMobNumberDTO.StrucDivMobNum; DB.DepartmentMobNumbers.Update(departmentMobNumber); DB.Save(); } }
public void CreateDepartmentMobNumber(DepartmentMobNumberDTO departmentMobNumberDTO) { DepartmentMobNumber departmentMobNumber = DB.DepartmentMobNumbers.Find(p => p.StrucDivMobNum == departmentMobNumberDTO.StrucDivMobNum).FirstOrDefault(); if (departmentMobNumber == null) { DB.DepartmentMobNumbers.Create(new DepartmentMobNumber { Id = departmentMobNumberDTO.Id, StrucDivId = departmentMobNumberDTO.StrucDivId, StrucDivMobNum = departmentMobNumberDTO.StrucDivMobNum }); DB.Save(); } else { throw new ValidationException("Такой служебный моб. номер уже существует!", ""); } }