Esempio n. 1
0
        public async Task <ActionResultReponese <string> > InsertAsync(string NameFaculty, DepartmentMeta department)
        {
            var idfaculty = await _facultyRepository.CheckExitsFacult(NameFaculty);

            if (!idfaculty)
            {
                return(new ActionResultReponese <string>(-21, "khoa khong ton tai", "Faculty"));
            }
            var namedeartment = await _departmentRepository.CheckExitsDepartment(department.NameDepartment);

            if (namedeartment)
            {
                return(new ActionResultReponese <string>(-22, "Bo mon da ton tai", "Department"));
            }
            var _department = new Department
            {
                IdDepartment   = Guid.NewGuid().ToString(),
                NameDepartment = department.NameDepartment?.Trim(),
                Office         = department.Office?.Trim(),
                Addres         = department.Addres?.Trim(),
                Email          = department.Email?.Trim(),
                PhoneNumber    = department.PhoneNumber?.Trim(),
                IdFaculty      = department.IdFaculty?.Trim(),
                CreateDate     = DateTime.Now,
                LastUpdate     = null,
                IsActive       = true,
                IsDelete       = false,
                DeleteTime     = null
            };
            var Result = await _departmentRepository.InsertAsync(_department);

            if (Result >= 0)
            {
                return(new ActionResultReponese <string>(Result, "them thanh cong", "Department", null));
            }
            return(new ActionResultReponese <string>(Result, "them that bai", "Department", null));
        }