Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
        public IBasicRepository <TEntity> basicRepository;//通过在子类的构造函数中注入,这里是基类,不用构造函数

        public async Task <bool> Add(TEntity model)
        {
            return(await basicRepository.AddAsync(model));
        }