Пример #1
0
        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);
        }
Пример #2
0
        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();
     }
 }
Пример #4
0
 public void UpdateProduct(Product product)
 {
     using (var context = new OSContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #5
0
        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();
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
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);
        }