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