public static FacultyDomain Create(AddFacultyModel addFacultyModel)
 {
     return(new FacultyDomain(
                addFacultyModel.Title,
                addFacultyModel.FacultyCode
                ));
 }
Esempio n. 2
0
        public async Task <IActionResult> AddNewFaculty(AddFacultyModel model)
        {
            FacultyDTO newItem = new FacultyDTO()
            {
                facultyName    = model.Name,
                facultyAddress = model.Address
            };

            await faculty.Create(newItem);

            return(RedirectToAction("GetFaculty", "EducationalDepartment"));
        }
        public async Task <IDataResult <long> > AddAsync(AddFacultyModel addFacultyModel)
        {
            var validation = new FacultyModelValidator().Valid(addFacultyModel);

            if (!validation.Success)
            {
                return(new ErrorDataResult <long>(validation.Message));
            }

            var facultyDomain = FacultyDomainFactory.Create(addFacultyModel);

            facultyDomain.Add();

            var facultyEntity = facultyDomain.Map <FacultyEntity>();

            await FacultyRepository.AddAsync(facultyEntity);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessDataResult <long>(facultyEntity.FacultyId));
        }
        public async Task <IActionResult> AddAsync(AddFacultyModel addFacultyModel)
        {
            var result = await FacultyService.AddAsync(addFacultyModel);

            return(new ActionIResult(result));
        }