Ejemplo n.º 1
0
 public async Task <IActionResult> Post([FromBody] Faculty value)
 {
     try
     {
         var entity = _mapper.Map <BL.Faculty>(value);
         var id     = _service.SaveAsync(entity);
         return(Ok(id));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostAsync([FromBody] SaveFacultyResource resource)
        {
            var faculty = mapper.Map <SaveFacultyResource, Faculty>(resource);
            var result  = await facultyService.SaveAsync(faculty);

            if (!result.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PostAsync([FromBody] SaveFacultyResource resource, int universityId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            var faculty = _mapper.Map <SaveFacultyResource, Faculty>(resource);
            var result  = await _facultyService.SaveAsync(faculty, universityId);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }
            var facultyResource = _mapper.Map <Faculty, FacultyResource>(result.Resource);

            return(Ok(facultyResource));
        }