public async Task <IActionResult> PutJwelVendor(int id, [FromForm] JwelVendor jwelVendor) { if (id != jwelVendor.CompanyID) { return(BadRequest()); } if (jwelVendor.ImageFile != null) { DeleteImage(jwelVendor.ImageName); jwelVendor.ImageName = await SaveImage(jwelVendor.ImageFile); } _context.Entry(jwelVendor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JwelVendorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <JwelVendor> > PostJwelVendor([FromForm] JwelVendor jwelVendor) { jwelVendor.ImageName = await SaveImage(jwelVendor.ImageFile); _context.Jwellers.Add(jwelVendor); await _context.SaveChangesAsync(); return(StatusCode(201)); }