public async Task <IActionResult> PutFileUpload(int id, FileUpload fileUpload) { if (id != fileUpload.Id) { return(BadRequest()); } _context.Entry(fileUpload).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FileUploadExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public IHttpActionResult Putmessage(int id, message message) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != message.msgID) { return(BadRequest()); } db.Entry(message).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!messageExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutSessionTypes(int id, SessionTypes sessionTypes) { if (id != sessionTypes.Id) { return(BadRequest()); } _context.Entry(sessionTypes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SessionTypesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUsers(int id, Users users) { if (id != users.Id) { return(BadRequest()); } //have to do password hash and stuff _context.Entry(users).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutTestDB(int id, TestDB testDB) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != testDB.ID) { return(BadRequest()); } db.Entry(testDB).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TestDBExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutUserDetails(int id, UserDetails userDetails) { if (id != userDetails.UserId) { return(BadRequest()); } _context.Entry(userDetails).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,TestCode,TestName,Description,Charges")] Test test) { if (ModelState.IsValid) { db.Entry(test).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(test)); }
public ActionResult Edit([Bind(Include = "Id,Cidade,Estado,País")] Table table) { if (ModelState.IsValid) { db.Entry(table).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(table)); }
public async Task <IActionResult> PutTodoItem(int id, TodoItem item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Delete(int?id) { if (id != null) { TestCase testCase = new TestCase { Id = id.Value }; db.Entry(testCase).State = EntityState.Deleted; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(NotFound()); }
public async Task UpdateEmployee(Employee employee) { _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.Id)) { throw new NotFoundException(); } else { throw; } } }
public void Update(Product product) { try { Product productToUpdate = GetAllProducts().Where(x => x.ProductCategoryID == product.ProductCategoryID).FirstOrDefault(); if (productToUpdate != null) { productToUpdate.Name = product.Name; productToUpdate.ValidFrom = product.ValidFrom; productToUpdate.Quantity = product.Quantity; productToUpdate.Price = product.Price; testDBContext.Products.Attach(productToUpdate); testDBContext.Entry(productToUpdate).State = EntityState.Modified; testDBContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(T entity) { _dbSet.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }