示例#1
0
 public static void MappingChiTietHD(this ChiTietHDDto cthddto, ChiTietHD cthd)
 {
     // q.permission_id = cthddto.permission_id;
     cthd.name   = cthddto.name;
     cthd.amount = cthddto.amount;
     cthd.price  = cthddto.price;
     cthd.img    = cthddto.img.Replace(Constants.apiUrlImg, "");
 }
示例#2
0
 public static ChiTietHD MappingChiTietHD(this ChiTietHDDto cthddto)
 {
     return(new ChiTietHD {
         bill_id = cthddto.bill_id,
         product_id = cthddto.product_id,
         name = cthddto.name,
         amount = cthddto.amount,
         price = cthddto.price,
         img = cthddto.img.Replace(Constants.apiUrlImg, "")
     });
 }
示例#3
0
        public void AddCTHDRange(CTHD_billID_List q)
        {
            List <ChiTietHDDto> list = new List <ChiTietHDDto>();

            string[] dauVa = q.list.Split('&');
            int      product_id, amount;

            // Load danh sách sản phẩm vào chi tiết hóa đơn
            for (var i = 0; i < dauVa.Length - 1; ++i)
            {
                string[] dauNgang = dauVa[i].Split('-');

                bool success = int.TryParse(dauNgang[0], out product_id);
                if (success)
                {
                    success = int.TryParse(dauNgang[1], out amount);
                    if (!success)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }

                var sp = SPService.SanPham_GetById(product_id);

                // Update số lượng sản phẩm khi đặt hàng
                sp.amount = sp.amount - amount;
                SPService.SanPham_Update(sp);

                var cthd = new ChiTietHDDto();
                cthd.bill_id    = q.bill_id;
                cthd.product_id = product_id;
                cthd.name       = sp.name;
                cthd.amount     = amount;
                cthd.price      = sp.price;
                cthd.img        = sp.img;

                list.Add(cthd);
            }

            CTHDservice.ChiTietHD_AddRange(list);
        }
示例#4
0
        public ActionResult <ChiTietHDDto> AddCTHDDto(ChiTietHDDto q)
        {
            CTHDservice.ChiTietHD_Add(q);

            return(q);
        }
示例#5
0
        public void ChiTietHD_Add(ChiTietHDDto hddto)
        {
            var cthd = hddto.MappingChiTietHD();

            CTHDcontext.ChiTietHD_Add(cthd);
        }