public async Task <IActionResult> PutFeedback(int id, Feedback feedback) { if (id != feedback.FeedbackId) { return(BadRequest()); } _context.Entry(feedback).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FeedbackExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutInventoryReceivingNote(int id, InventoryReceivingNote inventoryReceivingNote) { if (id != inventoryReceivingNote.InventoryReceivingId) { return(BadRequest()); } _context.Entry(inventoryReceivingNote).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InventoryReceivingNoteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAccount(int id, Account account) { if (id != account.AccountId) { return(BadRequest()); } _context.Entry(account).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBillDetail(int id, BillDetail billDetail) { if (id != billDetail.BillDetailId) { return(BadRequest()); } _context.Entry(billDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BillDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDeliveryProduct(int id, DeliveryProduct deliveryProduct) { if (id != deliveryProduct.DeliveryProductId) { return(BadRequest()); } _context.Entry(deliveryProduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeliveryProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustomerType(int id, CustomerType customerType) { if (id != customerType.CustomerTypeId) { return(BadRequest()); } _context.Entry(customerType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDistributor(int id, Distributor distributor) { if (id != distributor.DistributorId) { return(BadRequest()); } _context.Entry(distributor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DistributorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUserProfile(int id, UserProfile userProfile) { if (id != userProfile.UserProfileId) { return(BadRequest()); } _context.Entry(userProfile).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserProfileExists(id)) { return(NotFound()); } else { throw; } } return(Ok(userProfile)); }
public async Task <IActionResult> PutMyBill(int id, Bill bill) { if (id == bill.BillId && bill.UserProfileId == GetProfileId()) { if (!(_context.Bill.Find(bill.BillId).UserProfileId == GetProfileId())) { return(Unauthorized()); } else { var local = _context.Set <Bill>() .Local .FirstOrDefault(entry => entry.BillId.Equals(id)); // check if local is not null if (local != null) { // detach _context.Entry(local).State = EntityState.Detached; } // set Modified flag in your entry _context.Entry(bill).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(NoContent()); } catch (DbUpdateConcurrencyException) { if (!BillExists(id)) { return(NotFound()); } else { throw; } } } } return(Unauthorized()); }