public async Task <RefreshTokenEntity> UpdateAsync(RefreshTokenEntity token) { var local = _OSContext.RefreshToken.Local.FirstOrDefault(entity => entity.Id == token.Id); if (local is not null) { _OSContext.Entry(local).State = EntityState.Detached; } _OSContext.Entry(token).State = EntityState.Modified; await _OSContext.SaveChangesAsync(); _Logger.LogInformation("(Repository) Token Updated: {1}", token.UserId); return(token); }
public async Task <UserEntity> UpdateAsync(UserEntity user) { var local = _OSContext.User.Local.FirstOrDefault(entity => entity.Id == user.Id); if (local is not null) { _OSContext.Entry(local).State = EntityState.Detached; } _OSContext.Entry(user).State = EntityState.Modified; await _OSContext.SaveChangesAsync(); _Logger.LogInformation("(Repository) User Updated: {1}", user.Id); return(user); }
public void UpdateCategory(Category category) { using (var context = new OSContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void UpdateProduct(Product product) { using (var context = new OSContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveProduct(Product product) { using (var context = new OSContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Unchanged; context.Products.Add(product); context.SaveChanges(); } }
public bool UpdateOrderStatus(int ID, string status) { using (var context = new OSContext()) { var order = context.Orders.Find(ID); order.Status = status; context.Entry(order).State = EntityState.Modified; return(context.SaveChanges() > 0); } }
public virtual async Task <T> UpdateAsync(T t, object key) { if (t == null) { return(null); } T exist = await Context.Set <T>().FindAsync(key); if (exist != null) { //TODO :: Rever log aqui. //string log = Newtonsoft.Json.JsonConvert.SerializeObject(exist); Context.Entry(exist).CurrentValues.SetValues(t); await Context.SaveChangesAsync(); } return(exist); }