Exemplo 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));
        }
        public async Task <ActionResultReponese <string> > InsertAsync(FacultyMeta facultyMeTa)
        {
            var isFaculty = await _facultyRepository.CheckExitsFacult(facultyMeTa.NameFaculty);

            if (isFaculty)
            {
                return(new ActionResultReponese <string>(-21, "IdFaculty da ton tai", "Faculty", null));
            }
            var _faculty = new Faculty
            {
                IdFaculty   = Guid.NewGuid().ToString(),
                NameFaculty = facultyMeTa?.NameFaculty.Trim(),
                IsActive    = true,
                IsDelete    = false
            };
            var Result = await _facultyRepository.InsertAsync(_faculty);

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