public async Task <bool> CreateGarage(CreateGarage model) { var entity = new Garage() { CollectorId = _userId, Name = model.Name, Location = model.Location }; _context.Garages.Add(entity); return(await _context.SaveChangesAsync() == 1); }
public async Task <IHttpActionResult> Post(CreateGarage garage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateGarageService(); if (!(await service.CreateGarage(garage))) { return(InternalServerError()); } return(Ok(garage)); }