Example #1
0
        public ActionResult SaveLandingPic(string pic)
        {
            try
            {
                using (linqDBContext db = new linqDBContext())
                {
                    var chk = (from us in db.tblItemPictures
                               where us.itemID == 0
                               select us).FirstOrDefault();
                    if (chk != null)
                    {
                        chk.picLocation = pic;
                        db.SaveChanges();
                    }
                    else
                    {
                        tblItemPicture p = new tblItemPicture();
                        p.itemID      = 0;
                        p.picLocation = pic;
                        db.tblItemPictures.Add(p);
                        db.SaveChanges();
                    }
                }

                return(Json(new { status = "success", Data = "Done" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception x)
            {
                return(Json(new { status = "error", Data = x.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public ActionResult AddProduct(string code, string name, string fabric, string priceO, string discount, string priceNet, int cat, string mcat, int lotId, string articleId, string desc, string[] picsArr)
        {
            try
            {
                int assignedID = 0;
                using (linqDBContext db = new linqDBContext())
                {
                    int getCatId = (from a in db.tblMainCategories where a.name == mcat select a.id).FirstOrDefault();


                    tblItem it = new tblItem();
                    it.itemCode      = code;
                    it.itemName      = name;
                    it.fabric        = fabric;
                    it.originalPrice = Convert.ToDecimal(priceO);
                    it.discount      = Convert.ToDecimal(discount);
                    it.netPrice      = Convert.ToDecimal(priceNet);
                    it.subCategory   = cat;
                    it.mainCategory  = getCatId;
                    it.description   = desc;
                    it.tag           = "";
                    it.articleId     = articleId;
                    it.lotId         = lotId;
                    it.date          = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    db.tblItems.Add(it);
                    db.SaveChanges();
                    assignedID = it.id;


                    if (picsArr != null)
                    {
                        foreach (var item in picsArr)
                        {
                            //var physicalPath = Path.Combine(Server.MapPath(subPath), item);
                            tblItemPicture p = new tblItemPicture();
                            p.itemID      = assignedID;
                            p.picLocation = item;
                            db.tblItemPictures.Add(p);
                            db.SaveChanges();
                        }
                    }
                }

                return(Json(new JsonResult()
                {
                    Data = assignedID
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception x)
            {
                return(Json(new { status = "error", Data = x.Message }, JsonRequestBehavior.AllowGet));
            }
        }