Beispiel #1
0
 public ActionResult Actions(string key, string codec, string codep, string codei, decimal value, int type, int pi)
 {
     if (key == Keyapi)
     {
         decimal dateEnd;
         var     date = Date(out dateEnd);
         var     obj  = Cates.FirstOrDefault(m => m.Barcode == codec);
         if (obj != null)
         {
             obj.Pi = pi;
             var objp = obj.ListProductValueItems.FirstOrDefault(m => m.Barcode == codep);
             if (objp != null)
             {
                 var a          = (objp.Price * value) ?? 0;
                 var pricetotal = Math.Round(a / 500000, 0) * 500;
                 var obji       = objp.ListImportProductItems.FirstOrDefault(m => m.BarCode == codei);
                 if (obji != null)
                 {
                     if (type == 2)
                     {
                         obj.Stt       = obji.Stt;
                         obji.Value    = value;
                         obji.PriceNew = pricetotal;
                         obji.IsIn     = true;
                         obji.Date     = date;
                         obji.DateEnd  = dateEnd;
                         return(Json(obji, JsonRequestBehavior.AllowGet));
                     }
                     if (type == 3)
                     {
                         objp.ListImportProductItems.Remove(obji);
                     }
                 }
                 else
                 {
                     obji = new ImportProductAddItem
                     {
                         Stt      = objp.ListImportProductItems.OrderByDescending(m => m.Stt).Select(m => m.Stt).FirstOrDefault() + 1,
                         BarCode  = codei,
                         Price    = objp.Price,
                         Value    = value,
                         PriceNew = pricetotal,
                         Quantity = 1,
                         IsIn     = value > 0,
                         Date     = date,
                         DateEnd  = dateEnd
                     };
                     obj.Stt = obji.Stt;
                     objp.ListImportProductItems.Add(obji);
                     return(Json(obji, JsonRequestBehavior.AllowGet));
                 }
             }
         }
     }
     return(Json(new ImportProductAddItem(), JsonRequestBehavior.AllowGet));
 }
Beispiel #2
0
 public ActionResult GetListSimpleProductDetail(string codec)
 {
     if (Request["key"] == Keyapi)
     {
         var obj = Cates.FirstOrDefault(m => m.Barcode == codec);
         if (obj == null)
         {
             var stt            = 1;
             var listItemDetail = _da.GetListSimpleProductDetail();
             foreach (var item in listItemDetail)
             {
                 item.Stt     = stt;
                 item.Barcode = FDIUtils.RandomCode(8);
                 item.Code    = "f" + stt;
                 stt++;
                 var objinew = new ImportProductAddItem
                 {
                     Stt      = 1,
                     BarCode  = FDIUtils.RandomCode(10),
                     Price    = item.Price,
                     Value    = 0,
                     PriceNew = 0,
                     Quantity = 1,
                 };
                 item.ListImportProductItems = new List <ImportProductAddItem> {
                     objinew
                 };
             }
             obj = new CateValueAddItem
             {
                 Stt      = 1,
                 Barcode  = codec,
                 PriceNew = 0,
                 Pi       = 0,
                 ListProductValueItems = listItemDetail,
             };
             Cates.Add(obj);
         }
         return(Json(obj, JsonRequestBehavior.AllowGet));
     }
     return(Json(new CateValueAddItem(), JsonRequestBehavior.AllowGet));
 }