Ejemplo n.º 1
0
 public int SaveOrder(Order order)
 {
     using (var context = new GPSContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
Ejemplo n.º 2
0
 public void UpdateCategory(Category category)
 {
     using (var context = new GPSContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void Update(TEntity obj)
 {
     using (var ctx = new GPSContext())
     {
         ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void SaveCategory(Category category)
 {
     using (var context = new GPSContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
 public void UpdateProduct(Product Product)
 {
     using (var context = new GPSContext())
     {
         context.Entry(Product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void Add(TEntity obj)
 {
     using (var ctx = new GPSContext())
     {
         ctx.Set <TEntity>().Add(obj);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public void AddRange(IEnumerable <Empresa> empresas)
 {
     using (var ctx = new GPSContext())
     {
         ctx.Empresas.AddRange(empresas);
         ctx.SaveChanges();
     }
 }
        public void SaveProduct(Product Product)
        {
            using (var context = new GPSContext())
            {
                context.Entry(Product.Category).State = System.Data.Entity.EntityState.Unchanged;

                context.Products.Add(Product);
                context.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        public Circle InsertCirlce(Circle circle)
        {
            try
            {
                _context.Circle.Add(circle);
                _context.SaveChanges();

                return(circle);
            }
            catch (SqlException ex)
            {
                _logger.LogWarning("InsertCirlce method couldn't work, because of DB connection error: {ErrorMessage}", ex.Message);
            }
            catch (Exception ex)
            {
                _logger.LogWarning("InsertCirlce method couldn't work, because of this error: {ErrorMessage}", ex.Message);
            }

            return(null);
        }
        public void DeleteProduct(int ID)
        {
            using (var context = new GPSContext())
            {
                var Product = context.Products.Find(ID);
                //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
                context.Products.Remove(Product);

                context.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        public void DeleteCategory(int ID)
        {
            using (var context = new GPSContext())
            {
                var category = context.Categories.Where(x => x.ID == ID).Include(x => x.Products).FirstOrDefault();
                //context.Entry(category).State = System.Data.Entity.EntityState.Deleted;

                context.Products.RemoveRange(category.Products);
                context.Categories.Remove(category);

                context.SaveChanges();
            }
        }
        public bool UpdateOrderStatus(int ID, string status)
        {
            using (var context = new GPSContext())
            {
                var order = context.Orders.Find(ID);

                order.Status = status;

                context.Entry(order).State = EntityState.Modified;

                return(context.SaveChanges() > 0);
            }
        }
Ejemplo n.º 13
0
 public void Add(Trace entity)
 {
     _context.Traces.Add(entity);
     _context.SaveChanges();
 }
Ejemplo n.º 14
0
 public void Add(Payment entity)
 {
     _context.Payments.Add(entity);
     _context.SaveChanges();
 }
Ejemplo n.º 15
0
 public void Add(Client entity)
 {
     _context.Clients.Add(entity);
     _context.SaveChanges();
 }