public async Task <IActionResult> PutSaloonVendor(int id, [FromForm] SaloonVendor saloonVendor) { if (id != saloonVendor.CompanyID) { return(BadRequest()); } if (saloonVendor.ImageFile != null) { DeleteImage(saloonVendor.ImageName); saloonVendor.ImageName = await SaveImage(saloonVendor.ImageFile); } _context.Entry(saloonVendor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SaloonVendorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <SaloonVendor> > PostSaloonVendor([FromForm] SaloonVendor saloonVendor) { saloonVendor.ImageName = await SaveImage(saloonVendor.ImageFile); _context.Saloons.Add(saloonVendor); await _context.SaveChangesAsync(); return(StatusCode(201)); }