public RespBase <SalesInvoceDetail> Update(SalesInvoceDetail model)
        {
            RespBase <SalesInvoceDetail> response = new RespBase <SalesInvoceDetail>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var item = context.SalesInvoceDetails.Where(x => x.SalesInvoceDetailID == model.SalesInvoceDetailID).FirstOrDefault();
                    item.Price         = model.Price;
                    item.Quantity      = model.Quantity;
                    item.SalesInvoceID = model.SalesInvoceID;
                    item.ProductID     = model.ProductID;
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoce> Get(int ID)
        {
            RespBase <SalesInvoce> response = new RespBase <SalesInvoce>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    response.Object = context.SalesInvoces
                                      .Include("Customer")
                                      .Include("Seller")
                                      .Include("SalesInvoceDetails.Product")
                                      .Where(x => x.SalesInvoceID == ID && x.State == true).FirstOrDefault();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoce> Update(SalesInvoce model)
        {
            RespBase <SalesInvoce> response = new RespBase <SalesInvoce>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var item = context.SalesInvoces.Where(x => x.SalesInvoceID == model.SalesInvoceID).FirstOrDefault();
                    item.Reason     = model.Reason;
                    item.SellerID   = model.SellerID;
                    item.CustomerID = model.CustomerID;
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 4
0
        public RespBase <Seller> Update(Seller model)
        {
            RespBase <Seller> response = new RespBase <Seller>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var seller = context.Sellers.Where(x => x.SellerID == model.SellerID).FirstOrDefault();
                    seller.Name      = model.Name;
                    seller.LastName  = model.LastName;
                    seller.Email     = model.Email;
                    seller.Birthdate = model.Birthdate;
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 5
0
        public RespBase <Product> Update(Product model)
        {
            RespBase <Product> response = new RespBase <Product>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var item = context.Products.Where(x => x.ProductID == model.ProductID).FirstOrDefault();
                    item.Name    = model.Name;
                    item.Stock   = model.Stock;
                    item.Price   = model.Price;
                    item.Remarks = model.Remarks;
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 6
0
        public RespBase <Customer> Update(Customer model)
        {
            RespBase <Customer> response = new RespBase <Customer>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var item = context.Customers.Find(model.CustomerID);
                    item.Name      = model.Name;
                    item.LastName  = model.LastName;
                    item.Birthdate = model.Birthdate;
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoceDetail> GetList()
        {
            RespBase <SalesInvoceDetail> response = new RespBase <SalesInvoceDetail>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    response.List = context.SalesInvoceDetails.ToList();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoceDetail> Get(int ID)
        {
            RespBase <SalesInvoceDetail> response = new RespBase <SalesInvoceDetail>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    response.List = context.SalesInvoceDetails.Include("Product").Include("SalesInvoce").Where(x => x.SalesInvoceID == ID).ToList();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoceSP> GetList()
        {
            RespBase <SalesInvoceSP> response = new RespBase <SalesInvoceSP>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    response.List = context.Database.SqlQuery <SalesInvoceSP>("pa_listSales").ToList();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 10
0
        public RespBase <Product> GetList()
        {
            RespBase <Product> response = new RespBase <Product>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    response.List = context.Products.Where(x => x.State == true).ToList();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 11
0
        public RespBase <Product> Get(int ID)
        {
            RespBase <Product> response = new RespBase <Product>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    response.Object = context.Products.Where(x => x.ProductID == ID && x.State == true).FirstOrDefault();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoceDetail> Add(SalesInvoceDetail model)
        {
            RespBase <SalesInvoceDetail> response = new RespBase <SalesInvoceDetail>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    model.State = true;
                    context.SalesInvoceDetails.Add(model);
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoceDetail> Delete(int ID)
        {
            RespBase <SalesInvoceDetail> response = new RespBase <SalesInvoceDetail>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var item = context.SalesInvoceDetails.Where(x => x.SalesInvoceDetailID == ID).FirstOrDefault();
                    context.SalesInvoceDetails.Remove(item);
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 14
0
        public RespBase <Product> Delete(int ID)
        {
            RespBase <Product> response = new RespBase <Product>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    var item = context.Products.Where(x => x.ProductID == ID).FirstOrDefault();
                    item.State = false;
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
        public RespBase <SalesInvoce> Add(SalesInvoce model)
        {
            RespBase <SalesInvoce> response = new RespBase <SalesInvoce>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    model.CreateAt  = DateTime.Now;
                    model.State     = true;
                    response.Object = context.SalesInvoces.Add(model);
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }
Esempio n. 16
0
        public RespBase <Customer> Add(Customer model)
        {
            model.State    = true;
            model.CreateAt = DateTime.Now;
            RespBase <Customer> response = new RespBase <Customer>();

            try
            {
                using (var context = new ProyectoFinalContext())
                {
                    context.Customers.Add(model);
                    context.SaveChanges();
                }
                response.IsSuccess = true;
                response.Message   = "Success";
                return(response);
            }
            catch (Exception ex)
            {
                response.Message   = ex.Message;
                response.IsSuccess = false;
                return(response);
            }
        }