Example #1
0
        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();
            }
        }
Example #2
0
        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
            });
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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("Такой служебный номер уже существует!", "");
            }
        }