Exemplo n.º 1
0
        public async Task <ActionResultReponese <string> > UpdateAsync(string IdDepartment, DepartmentMeta department)
        {
            var idfaculty = await _facultyRepository.CheckExitsIdFacult(department.IdFaculty);

            if (!idfaculty)
            {
                return(new ActionResultReponese <string>(-21, "khoa khong ton tai", "Faculty"));
            }
            var _department = new Department
            {
                IdDepartment   = IdDepartment?.Trim(),
                NameDepartment = department.NameDepartment?.Trim(),
                Office         = department.Office?.Trim(),
                Addres         = department.Addres?.Trim(),
                Email          = department.Email?.Trim(),
                PhoneNumber    = department.PhoneNumber?.Trim(),
                IdFaculty      = department.IdFaculty?.Trim(),
                LastUpdate     = DateTime.Now,
            };
            var Result = await _departmentRepository.UpdateAsync(_department);

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