public IActionResult getAllProduct()
        {
            var res = new SimpleRsp();

            res.Data = _svc.All;
            return(Ok(res));
        }
示例#2
0
        /// <summary>
        /// Read single object
        /// </summary>
        /// <param name="id">Primary key</param>
        /// <returns>Return the object</returns>
        public override SimpleRsp Read(int id)
        {
            var res = new SimpleRsp();
            var m   = _rep.Read(id);

            res.Data = m;
            return(res);
        }
        public IActionResult SearchProduct([FromBody] SearchProductReq req)
        {
            var res  = new SimpleRsp();
            var pros = _svc.SearchProduct(req.Keyword, req.Page, req.Size);

            res.Data = pros;
            return(Ok(res));
        }
        public IActionResult getCustOrderDetails_LinQ([FromBody] SimpleReq req)
        {
            var res = new SimpleRsp();
            var pro = _svc.getCustOrderDetails_LinQ(req.Id);

            res.Data = pro;
            return(Ok(res));
        }
        public IActionResult getCustOrderHist([FromBody] SimpleReq req)
        {
            var res = new SimpleRsp();
            var pro = _svc.getCustOrderHist(req.Keyword);

            res.Data = pro;
            return(Ok(res));
        }
        public IActionResult getProductById([FromBody] SimpleReq req)
        {
            var res = new SimpleRsp();
            var pro = _svc.Read(req.Id);

            res.Data = pro;
            return(Ok(res));
        }
        public IActionResult listOrder_Pagination([FromBody] RevenueReq req)
        {
            var res = new SimpleRsp();
            var pro = _svc.listOrder_Pagination(req.dateF, req.dateT, req.page, req.size);

            res.Data = pro;
            return(Ok(res));
        }
        public IActionResult getEmlandRevenuetheoNgay_LinQ([FromBody] RevenueReq req)
        {
            var res = new SimpleRsp();
            var pro = _svc.getEmlandRevenuetheoNgay_LinQ(req.dateF, req.dateT);

            res.Data = pro;
            return(Ok(res));
        }
示例#9
0
        /// <summary>
        /// Update the model
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public virtual SimpleRsp Update(T m)
        {
            var res = new SimpleRsp();

            try
            {
                _rep.Update(m);
            }
            catch (Exception ex)
            {
                res.SetError(ex.StackTrace);
            }

            return(res);
        }
示例#10
0
        public override SimpleRsp Update(Products m)
        {
            var res = new SimpleRsp();
            var m1  = m.ProductId > 0 ? _rep.Read(m.ProductId) : _rep.Read(m.ProductName);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }
            return(res);
        }
示例#11
0
        /// <summary>
        /// Create the model
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public virtual SimpleRsp Create(T m)
        {
            var res = new SimpleRsp();

            try
            {
                var now = DateTime.Now;
                _rep.Create(m);
            }
            catch (Exception ex)
            {
                res.SetError(ex.StackTrace);
            }

            return(res);
        }
示例#12
0
        // hàm create product

        public SimpleRsp CreateProduct(ProductsReq pro)
        {
            var res = new SimpleRsp();

            //gán đối tượng từ rep sang đối tượng database
            Products products = new Products();

            products.ProductId       = pro.ProductId;
            products.ProductName     = pro.ProductName;
            products.SupplierId      = pro.SupplierId;
            products.CategoryId      = pro.CategoryId;
            products.QuantityPerUnit = pro.QuantityPerUnit;
            products.UnitPrice       = pro.UnitPrice;
            products.UnitsInStock    = pro.UnitsInStock;
            products.ReorderLevel    = pro.ReorderLevel;
            products.Discontinued    = pro.Discontinued;

            // xử lý create
            res = _rep.CreateProduct(products);

            return(res);
        }
示例#13
0
        public object UpdateProduct(ProductsReq req)
        {
            var res = new SimpleRsp();

            //gán đối tượng từ rep sang đối tượng database
            Products products = new Products();

            products.ProductId       = req.ProductId;
            products.ProductName     = req.ProductName;
            products.SupplierId      = req.SupplierId;
            products.CategoryId      = req.CategoryId;
            products.QuantityPerUnit = req.QuantityPerUnit;
            products.UnitPrice       = req.UnitPrice;
            products.UnitsInStock    = req.UnitsInStock;
            products.ReorderLevel    = req.ReorderLevel;
            products.Discontinued    = req.Discontinued;

            //xử lý update
            res = _rep.UpdateProduct(products);

            return(res);
        }
示例#14
0
        // viết hàm Update
        public SimpleRsp UpdateProduct(Products pro)
        {
            var res = new SimpleRsp();

            using (var context = new NorthwindContext())
            {
                using (var tran = context.Database.BeginTransaction())
                {
                    try
                    {
                        var t = context.Products.Update(pro);
                        context.SaveChanges();
                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        res.SetError(ex.StackTrace);
                    }
                }
            }
            return(res);
        }