public async Task <IActionResult> PostAsync( [FromBody] Contact contact) { return(contact == null ? new BadRequestResult() : ModelState.IsValid ? new OkObjectResult(await _repo.AddAsync(contact, User)) : (IActionResult) new BadRequestObjectResult(ModelState)); }
public async Task <IActionResult> PostAsync( [FromBody] Vehicle vehicle) { vehicle.Tank = Vehicles.Shared.FuelLevel.Full.ToString(); return(vehicle == null ? new BadRequestResult() : ModelState.IsValid ? new OkObjectResult(await _repo.AddAsync(vehicle, User)) : (IActionResult) new BadRequestObjectResult(ModelState)); }
public IBasicRepository <TEntity> basicRepository;//通过在子类的构造函数中注入,这里是基类,不用构造函数 public async Task <bool> Add(TEntity model) { return(await basicRepository.AddAsync(model)); }