public async Task UpdateCategoryAsync(Category category) { try { _context.Entry <Category>(category).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception("An error has occurred"); } }
public async Task UpdateBrandAsync(Brand brand) { try { _context.Entry <Brand>(brand).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception("An error has occurred"); } }
public async Task DeleteProductAync(Guid id) { try { Product obj = await _context.Products.FindAsync(id); _context.Entry <Product>(obj).State = EntityState.Deleted; await _context.SaveChangesAsync(); } catch (ArgumentNullException ex) { throw new ArgumentNullException(ex.Message); } }
public Group Save(Group item) { try { item.Teams.ToList().ForEach(s => _context.Entry(s).State = EntityState.Modified); _context.Group.Add(item); _context.SaveChanges(); return(item); } catch (Exception e) { return(null); } }
public Payment Put([FromBody] Payment payment) { _context.Entry <Payment>(payment).State = EntityState.Modified; _context.SaveChanges(); return(payment); }
public Product Put([FromBody] Product product) { _context.Entry <Product>(product).State = EntityState.Modified; _context.SaveChanges(); return(product); }
public User Put([FromBody] User user) { _context.Entry <User>(user).State = EntityState.Modified; _context.SaveChanges(); return(user); }
public Category Update(Category category) { _context.Entry <Category>(category).State = EntityState.Modified; _context.SaveChanges(); return(category); }
public Match Update(Match item) { _context.Entry <Match>(item).State = EntityState.Modified; _context.SaveChanges(); return(item); }
public Enrolment Put([FromBody] Enrolment enrolment) { _context.Entry <Enrolment>(enrolment).State = EntityState.Modified; _context.SaveChanges(); return(enrolment); }
public LivingRoom Put([FromBody] LivingRoom livingRoom) { _context.Entry <LivingRoom>(livingRoom).State = EntityState.Modified; _context.SaveChanges(); return(livingRoom); }
public Course Put([FromBody] Course course) { _context.Entry <Course>(course).State = EntityState.Modified; _context.SaveChanges(); return(course); }
public Account Put([FromBody] Account account) { _context.Entry <Account>(account).State = EntityState.Modified; _context.SaveChanges(); return(account); }
public async Task <Category> SaveCategory(Category category) { _context.Entry <Category>(category).State = EntityState.Modified; await _context.SaveChangesAsync(); return(category); }
public async Task <Survivor> Update(Survivor survivor) { _context.Entry <Survivor>(survivor).State = EntityState.Modified; _context.SaveChanges(); return(survivor); }
public User Update(User user) { _context.Entry <User>(user).State = EntityState.Modified; _context.SaveChanges(); return(user); }
public Student Put([FromBody] Student student) { _context.Entry <Student>(student).State = EntityState.Modified; _context.SaveChanges(); return(student); }
public async Task <ShelterStock> Update(ShelterStock shelterStock) { _context.Entry <ShelterStock>(shelterStock).State = EntityState.Modified; _context.SaveChanges(); return(shelterStock); }
public Category Put([FromBody] Category category) { _context.Entry <Category>(category).State = EntityState.Modified; _context.SaveChanges(); return(category); }
public async Task <Resource> Update(Resource resource) { _context.Entry <Resource>(resource).State = EntityState.Modified; _context.SaveChanges(); return(resource); }
public ResultViewModel Put([FromBody] EditProductViewModel model) { model.Validate(); if (model.Invalid) { return new ResultViewModel { Success = false, Message = "Não foi possível alterar o produto!", Data = model.Notifications } } ; Product product = _context.Products.Find(model.Id); product.Title = model.Title; product.CategoryId = model.CategoryId; product.Descriptions = model.Description; product.Image = model.Image; product.LastUpdateDate = DateTime.Now; product.Price = model.Price; product.Quantity = model.Quantity; _context.Entry <Product>(product).State = EntityState.Modified; _context.SaveChanges(); return(new ResultViewModel { Success = true, Message = "Produto alterado com sucesso!", Data = product }); } }
public Subscription Put([FromBody] Subscription subscription) { _context.Entry <Subscription>(subscription).State = EntityState.Modified; _context.SaveChanges(); return(subscription); }
public Card Put([FromBody] Card card) { _context.Entry <Card>(card).State = EntityState.Modified; _context.SaveChanges(); return(card); }
public Product Update(Product product) { _context.Entry <Product>(product).State = EntityState.Modified; _context.SaveChanges(); return(product); }
public Category Put([FromBody] Category category) { //QUando usamos o entitystate.modified ele faz o update no destino na minha modelo _context.Entry <Category>(category).State = EntityState.Modified; _context.SaveChanges(); return(category); }
public T Editar(T entity) { //Sem o Entry //var editar = Obter(entity.Id); //editar.Nome = cliente.Nome; //.. _ctx.Entry(entity).State = EntityState.Modified; salvar(); return(entity); }
public async Task <ActionResult> PutCategory( [FromServices] StoreDataContext _context, [FromBody] Category category) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Entry <Category>(category).State = EntityState.Modified; await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(PutCategory), category)); }
public Team Update(Team item) { try { _context.Entry <Team>(item).State = EntityState.Modified; _context.SaveChanges(); return(item); } catch (Exception e) { return(null); } }
public async Task <bool> Put(Category category) { bool resultUpdate = false; try { context.Entry <Category>(category).State = EntityState.Modified; int resultLine = await context.SaveChangesAsync(); resultUpdate = resultLine > 0 ? true : false; } catch (Exception ex) { Console.WriteLine("Put -> " + ex.Message); } return(resultUpdate); }
public virtual async Task UpdateAsync(T entity) { using (StoreDataContext dataContext = new StoreDataContext()) { try { entity.ModifyDateTime = DateTime.Now; dataContext.Entry(entity).State = EntityState.Modified; dataContext.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { var entry = ex.Entries.Single(); } } }