public TMSRace Add(TMSRaceCreateViewModel Vm) { var entity = _mapper.Map <TMSRaceCreateViewModel, TMSRace>(Vm); _itmsRaceRepository.Add(entity); SaveChanges(); return(entity); }
public IActionResult Add([FromBody] TMSRaceCreateViewModel Vm) { if (!ModelState.IsValid) { var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(new GenericResult(false, allErrors))); } else { try { _tmsRaceService.Add(Vm); return(new OkObjectResult(new GenericResult(true, "Add success!!!"))); } catch (Exception ex) { return(new OkObjectResult(new GenericResult(false, ex.Message))); } } }