public JsonResult SaveProduct(VM_Product aProduct) { if (ModelState.IsValid) { try { tblProductInformation product = new tblProductInformation(); product.ProductName = aProduct.ProductName; product.ProductTypeId = aProduct.ProductTypeId; product.StoreId = aProduct.StoreId; product.Unit = aProduct.Unit; product.UnitPrice = (decimal)aProduct.UnitPrice; product.ProductionCost = (decimal)aProduct.ProductionCost; product.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); product.CreatedBy = SessionManger.LoggedInUser(Session); product.CreatedDateTime = DateTime.Now; product.EditedBy = null; product.EditedDateTime = null; unitOfWork.ProductRepository.Insert(product); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Product Added Successfully." })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddProduct() { VM_Product vm = new VM_Product(); if (Mid < 1) { if (ModelID < 1) { function.WriteErrMsg("没有指定要添加内容的模型ID!"); return(null); } if (NodeID < 1) { function.WriteErrMsg("没有指定要添加内容的栏目节点ID!"); return(null); } vm.proMod = new M_Product() { Stock = 10, Rateset = 1, Dengji = 3 }; vm.NodeID = NodeID; vm.ModelID = ModelID; vm.proMod.ProCode = B_Product.GetProCode(); } else { vm.proMod = proBll.GetproductByid(Mid); vm.NodeID = vm.proMod.Nodeid; vm.ModelID = vm.proMod.ModelID; vm.ValueDT = proBll.GetContent(vm.proMod.TableName, vm.proMod.ItemID); if (!string.IsNullOrEmpty(vm.proMod.BindIDS))//捆绑商品 { DataTable dt = proBll.SelByIDS(vm.proMod.BindIDS, "id,Thumbnails,Proname,LinPrice"); vm.bindList = JsonConvert.SerializeObject(dt); } #region 特选商品 { string where = string.Format("(ProIDS LIKE '%,{0},%' OR ProIDS LIKE '{0},%' OR ProIDS LIKE '%,{0}')", vm.proMod.ID.ToString()); DataTable dt = DBCenter.SelWithField("ZL_User_BindPro", "UserID", where); string uids = StrHelper.GetIDSFromDT(dt, "UserID"); ViewBag.prouids = uids; } #endregion } //------------------------------------------------------------------------------------------------ vm.nodeMod = nodeBll.SelReturnModel(vm.NodeID); if (vm.nodeMod.IsNull) { function.WriteErrMsg("节点[" + NodeID + "]不存在"); return(null); } return(View(vm)); }
public List <VM_Product> GetPursableProductByProductionHouseList(int storeId) { //unitOfWork.SuppliersProductRepository.Get().Where(a=>a.) //Get All pursable Product var pursableProduct = unitOfWork.ProductRepository.Get().Where(a => a.ProductTypeId == (int)ProductType.PurchaseTypeProduct || a.ProductTypeId == (int)ProductType.PurchaseAndSellTypeProduct).ToList(); //list of pusable product status List <VM_Product> products = new List <VM_Product>(); foreach (var product in pursableProduct) { VM_Product vm_Product = new VM_Product(); vm_Product.ProductName = product.ProductName; vm_Product.Unit = product.Unit; vm_Product.UnitPrice = Convert.ToDecimal(unitOfWork.ProductRepository.GetByID(product.ProductId).UnitPrice); //product tranfer history ,list of product in and list of product out var productTranfer = unitOfWork.ProductTransferRepository.Get() .Where(a => a.ProductId == product.ProductId && a.StoreId == storeId).ToList(); var productIn = (decimal)productTranfer.Where(a => a.isIn == true).Select(a => a.Quantity).Sum(); var productOut = (decimal)productTranfer.Where(a => a.isOut == true).Select(a => a.Quantity).Sum(); if (productIn > productOut) { vm_Product.Quantity = Convert.ToDecimal(productIn - productOut); vm_Product.TotalPrice = Convert.ToDecimal(vm_Product.Quantity * vm_Product.UnitPrice); products.Add(vm_Product); } } return(products); }
public ActionResult AddProduct() { M_CommonData storeMod = conBll.SelMyStore_Ex(ref err); if (!string.IsNullOrEmpty(err)) { function.WriteErrMsg(err); return(null); } M_Product pinfo = new M_Product(); if (Mid > 0) { pinfo = proBll.GetproductByid(Mid); if (pinfo.UserShopID != storeMod.GeneralID) { function.WriteErrMsg("你无权修改该商品"); return(Content("")); } } VM_Product model = new VM_Product(pinfo, Request); return(View(model)); }
public async Task <VM_Product> GetProductById(int id) { Product productContext = await _context.Products.FirstOrDefaultAsync(x => x.Id == id); VM_Product product = null; if (productContext != null) { product = new VM_Product() { Id = productContext.Id, Name = productContext.Name, Price = productContext.Price, Quantity = productContext.Quantity, Decription = productContext.Decription, CategoryId = productContext.Category.Id, CategoryName = productContext.Category.Name, OriginalPrice = productContext.OriginalPrice, ImageProducts = productContext.ImageProducts }; } return(product); }
public JsonResult UpdateProduct(VM_Product aProduct) { tblProductInformation productInformation = unitOfWork.ProductRepository.GetByID(aProduct.ProductId); productInformation.ProductId = aProduct.ProductId; productInformation.ProductName = aProduct.ProductName; productInformation.ProductTypeId = aProduct.ProductTypeId; productInformation.StoreId = aProduct.StoreId; productInformation.Unit = aProduct.Unit; productInformation.UnitPrice = (decimal)aProduct.UnitPrice; productInformation.ProductionCost = aProduct.ProductionCost; productInformation.EditedBy = SessionManger.LoggedInUser(Session); productInformation.EditedDateTime = DateTime.Now; try { unitOfWork.ProductRepository.Update(productInformation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Successfully Edited" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ProductQuickView() { int Product_ID = Convert.ToInt32(Request.QueryString["Product_ID"]); using (DataContext dc = new DataContext()) { var displayproductrecord = dc.FF_Products.Where(a => a.ID == Product_ID).AsEnumerable(); var ProductAllImages = MyHelperClass.GetProduct_Images(Product_ID); VM_Product model = new VM_Product(); model.ID = displayproductrecord.First().ID; model.Product_Name = displayproductrecord.First().Product_Name; model.Product_Code = displayproductrecord.First().Product_Code; model.Price = displayproductrecord.First().Price; model.Discount = displayproductrecord.First().Discount; model.Quantity = displayproductrecord.First().Quantity; model.Description = displayproductrecord.First().Description; model.ImageCollection = ProductAllImages; return(PartialView("_ProductQuickView", model));//F:\MVC-New\FennyFeeds\FennyFeeds\Views\Shared\_ProductQuickView.cshtml } }
public List <VM_Product> GetSellAbleProductByProductionHouseList(int storeId) { var sellAbleProduct = unitOfWork.ProductionHouseToProductMappingRepository.Get().Where(a => a.ProductionHouseId == storeId).ToList(); //list of pusable product status List <VM_Product> products = new List <VM_Product>(); foreach (var product in sellAbleProduct) { VM_Product vm_Product = new VM_Product(); vm_Product.ProductName = product.tblProductInformation.ProductName; vm_Product.Unit = product.tblProductInformation.Unit; vm_Product.UnitPrice = Convert.ToDecimal(unitOfWork.ProductRepository.GetByID(product.ProductId).UnitPrice); //product tranfer history ,list of product in and list of product out var productTranfer = unitOfWork.ProductTransferRepository.Get() .Where(a => a.ProductId == product.ProductId && a.StoreId == storeId).ToList(); var productIn = productTranfer.Where(a => a.isIn == true).Select(a => a.Quantity).Sum(); var productOut = productTranfer.Where(a => a.isOut == true).Select(a => a.Quantity).Sum(); if (productIn > productOut) { vm_Product.Quantity = Convert.ToDecimal(productIn - productOut); vm_Product.TotalPrice = Convert.ToDecimal(vm_Product.Quantity * vm_Product.UnitPrice); products.Add(vm_Product); } } return(products); //return Json(new { success = true, result = products }, JsonRequestBehavior.AllowGet); }
public JsonResult GenerateReportForSearchResult(int sellsPointId, DateTime fromDate, DateTime toDate) { try { List <DAL.ViewModel.VM_Product> productList = unitOfWork.CustomRepository.sp_ProductSell(fromDate, toDate, sellsPointId); decimal totalAmount = 0; var newProductList = new List <VM_Product>(); foreach (var product in productList) { VM_Product newProduct = new VM_Product(); newProduct.ProductName = product.ProductName; newProduct.UnitPrice = product.UnitPrice; newProduct.Unit = product.Unit; newProduct.Quantity = product.Quantity; newProduct.TotalPrice = product.TotalPrice; newProductList.Add(newProduct); } totalAmount = productList.Select(s => s.TotalPrice).Sum(); string StoreName = unitOfWork.StoreRepository.GetByID(sellsPointId).store_name; int restaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString());; string restaurantName = unitOfWork.RestaurantRepository.GetByID(restaurantId).Name; string restaurantAddress = unitOfWork.RestaurantRepository.GetByID(restaurantId).Address; LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Reports/ProductSellReport.rdlc"); localReport.SetParameters(new ReportParameter("FromDate", fromDate.ToString())); localReport.SetParameters(new ReportParameter("ToDate", toDate.ToString())); localReport.SetParameters(new ReportParameter("StoreName", StoreName)); localReport.SetParameters(new ReportParameter("RestaurantName", restaurantName)); localReport.SetParameters(new ReportParameter("RestaurantAddress", restaurantAddress)); ReportDataSource reportDataSource = new ReportDataSource("ProductSellDataSet", newProductList); localReport.DataSources.Add(reportDataSource); string reportType = "pdf"; string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>0in</MarginLeft>" + " <MarginRight>0in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); var path = System.IO.Path.Combine(Server.MapPath("~/pdfReport")); var saveAs = string.Format("{0}.pdf", Path.Combine(path, "myfilename")); var idx = 0; while (System.IO.File.Exists(saveAs)) { idx++; saveAs = string.Format("{0}.{1}.pdf", Path.Combine(path, "myfilename"), idx); } Session["report"] = saveAs; using (var stream = new FileStream(saveAs, FileMode.Create, FileAccess.Write)) { stream.Write(renderedBytes, 0, renderedBytes.Length); stream.Close(); } localReport.Dispose(); return(Json(new { success = true, successMessage = "Product Report generated.", result = productList, TotalAmount = totalAmount }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddProduct() { VM_Product vm = new VM_Product(); if (!B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.shop, "product")) { return(null); } if (Mid < 1) { if (ModelID < 1) { function.WriteErrMsg("没有指定要添加内容的模型ID!"); return(null); } if (NodeID < 1) { function.WriteErrMsg("没有指定要添加内容的栏目节点ID!"); return(null); } vm.proMod = new M_Product() { Stock = 10, Rateset = 1, Dengji = 3 }; vm.NodeID = NodeID; vm.ModelID = ModelID; vm.proMod.ProCode = B_Product.GetProCode(); vm.ProGuid = Guid.NewGuid().ToString(); } else { int VerID = DataConvert.CLng(Request.QueryString["Ver"]); if (VerID > 0) { M_Content_VerBak verMod = verBll.SelReturnModel(VerID); vm.proMod = JsonConvert.DeserializeObject <M_Product>(verMod.ContentBak); if (vm.proMod.ID != Mid) { function.WriteErrMsg("加载的版本与商品不匹配"); return(null); } vm.ValueDT = JsonConvert.DeserializeObject <DataTable>(verMod.TableBak); } else { vm.proMod = proBll.GetproductByid(Mid); vm.ValueDT = proBll.GetContent(vm.proMod.TableName, vm.proMod.ItemID); } vm.ProGuid = vm.proMod.ID.ToString(); if (vm.proMod.Class == 2) { Response.Redirect(CustomerPageAction.customPath + "Shop/Arrive/SuitProAdd.aspx?ID=" + vm.proMod.ID); } vm.NodeID = vm.proMod.Nodeid; vm.ModelID = vm.proMod.ModelID; if (!string.IsNullOrEmpty(vm.proMod.BindIDS))//捆绑商品 { DataTable dt = proBll.SelByIDS(vm.proMod.BindIDS, "id,Thumbnails,Proname,LinPrice"); vm.bindList = JsonConvert.SerializeObject(dt); } //多区域价格 vm.regionMod = regionBll.SelModelByGuid(vm.ProGuid); if (vm.regionMod == null) { vm.regionMod = new M_Shop_RegionPrice(); } #region 特选商品 { string where = string.Format("(ProIDS LIKE '%,{0},%' OR ProIDS LIKE '{0},%' OR ProIDS LIKE '%,{0}')", vm.proMod.ID.ToString()); DataTable dt = DBCenter.SelWithField("ZL_User_BindPro", "UserID", where); string uids = StrHelper.GetIDSFromDT(dt, "UserID"); ViewBag.prouids = uids; } #endregion } //------------------------------------------------------------------------------------------------ vm.nodeMod = nodeBll.SelReturnModel(vm.NodeID); if (vm.nodeMod.IsNull) { function.WriteErrMsg("节点[" + vm.NodeID + "]不存在"); return(null); } return(View(vm)); }
public ActionResult ViewPdfReportForSearchResult(int sellsPointStoreId, string fromDate, int shiftId) { try { var date = DateTime.Parse(fromDate.ToString()); var printInfo = string.Format("{0:yyyy-MM-dd}", date); List <DAL.ViewModel.VM_Product> productList = unitOfWork.CustomRepository.sp_ProductEntryHistoryForSpecificDayInSellsPoint(Convert.ToDateTime(fromDate), sellsPointStoreId, shiftId); var newProductList = new List <VM_Product>(); int serial = 0; foreach (var product in productList) { VM_Product newProduct = new VM_Product(); newProduct.Serial = ++serial; newProduct.ProductName = product.ProductName; newProduct.ProductTypeName = product.ProductTypeName; newProduct.UnitPrice = product.UnitPrice; newProduct.Quantity = product.Quantity; newProduct.Unit = product.Unit; newProduct.TotalPrice = product.TotalPrice; newProductList.Add(newProduct); } string groupName; if (shiftId == 1) { groupName = unitOfWork.GroupAndShiftMappingRepository.Get() .Where(x => x.TransferDate.Value.Date == Convert.ToDateTime(printInfo)) .Select(a => a.Day) .FirstOrDefault(); } else { groupName = unitOfWork.GroupAndShiftMappingRepository.Get() .Where(x => x.TransferDate.Value.Date == Convert.ToDateTime(printInfo)) .Select(a => a.Night) .FirstOrDefault(); } int restaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); string restaurantName = unitOfWork.RestaurantRepository.GetByID(restaurantId).Name; string restaurantAddress = unitOfWork.RestaurantRepository.GetByID(restaurantId).Address; string sellsPointName = unitOfWork.StoreRepository.GetByID(sellsPointStoreId).store_name; string shiftName = unitOfWork.ShiftRepository.GetByID(shiftId).ShiftName; LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Reports/ProductEntryHistoryForSpecificDateInSellPointReport.rdlc"); localReport.SetParameters(new ReportParameter("FromDate", fromDate.ToString())); localReport.SetParameters(new ReportParameter("ShiftName", shiftName)); localReport.SetParameters(new ReportParameter("GroupName", groupName)); localReport.SetParameters(new ReportParameter("SellsPointName", sellsPointName)); localReport.SetParameters(new ReportParameter("RestaurantName", restaurantName)); localReport.SetParameters(new ReportParameter("RestaurantAddress", restaurantAddress)); ReportDataSource reportDataSource = new ReportDataSource("ProductEntryHistoryForSpecificDateInSellPointDataSet", newProductList); localReport.DataSources.Add(reportDataSource); string reportType = "pdf"; string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>0in</MarginLeft>" + " <MarginRight>0in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddProductDetails(VM_Product product)//VM_Product product, HttpPostedFileBase file1 //string Category_ID, string Brand { try { //return View(); int User_ID = Convert.ToInt32(SessionObject.userid ?? 0); if (User_ID == 0) { return(Json("session_expire", JsonRequestBehavior.AllowGet)); } FF_Products p = new FF_Products(); p.Category_ID = Convert.ToInt32(product.Category_ID); p.Sub_Category_ID = Convert.ToInt32(product.Sub_Category_ID); p.User_ID = User_ID; p.Brand = product.Brand; p.Product_Name = product.Product_Name; p.Product_Code = product.Product_Code; if (string.IsNullOrEmpty(product.Price)) { p.Price = "0"; } else { p.Price = product.Price; } if (string.IsNullOrEmpty(product.Quantity)) { p.Quantity = "0"; } else { p.Quantity = product.Quantity; } p.Discount = product.Discount; p.Description = product.Description; p.Image = ""; p.Creation_Date = DateTime.UtcNow; //p.IsProduct_Hide = "0"; interfaceobj.InsertModel(p); interfaceobj.Save(); // BELOW CODE IS TO ADD PRODUCT VARIANT// if (!string.IsNullOrEmpty(product.VariantCollection)) { string[] coll = product.VariantCollection.Split(new string[] { "<|>" }, StringSplitOptions.RemoveEmptyEntries); int sumofvariantquantiy = 0; foreach (var item in coll) { FF_Product_SubTable PST = new FF_Product_SubTable(); string[] split2 = item.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); PST.Product_Id = p.ID; PST.Product_Variant_Id = product.Product_Variant_Id; string GlobalVariantText = split2[0]; if (GlobalVariantText.ToLower() == "colour/size") { PST.Product_Size = split2[1]; PST.Product_Colour = split2[2]; PST.Product_Price = split2[3]; PST.Product_Quantity = split2[4]; sumofvariantquantiy += Convert.ToInt32(split2[4]); } else { if (GlobalVariantText.ToLower() == "size") { PST.Product_Size = split2[1]; } else if (GlobalVariantText.ToLower() == "colour") { PST.Product_Colour = split2[1]; } else if (GlobalVariantText.ToLower() == "weight") { PST.Product_Weight = split2[1]; } PST.Product_Price = split2[2]; PST.Product_Quantity = split2[3]; sumofvariantquantiy += Convert.ToInt32(split2[3]); } interfaceobj_Product_SubTable.InsertModel(PST); } interfaceobj_Product_SubTable.Save(); //UPDATE QUANTITY(SUM) IN PRODUCT MAIN TABLE //var updateproductrecord = interfaceobj.GetModelById(p.ID); //updateproductrecord.Quantity = sumofvariantquantiy.ToString(); //updateproductrecord.Price = null; p.Quantity = sumofvariantquantiy.ToString(); p.Price = ""; interfaceobj.UpdateModel(p); interfaceobj.Save(); } // END// //return View(); //Product Image Uploding code int filecount = Request.Files.Count; if (filecount > 0) { // Get all files from Request object //HttpPostedFileBase postedfile = Request.Files[0]; HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFileBase postedfile = files[i]; string savepath = HttpContext.Server.MapPath("~/content/Product_Image/"); if (System.IO.Directory.Exists(savepath)) { //savepath += "Product_Image/"; //if (!System.IO.Directory.Exists(savepath)) //{ // System.IO.Directory.CreateDirectory(savepath); //} int ProductID = p.ID; savepath += ProductID + "/"; if (!System.IO.Directory.Exists(savepath)) { System.IO.Directory.CreateDirectory(savepath); } string FileName = DateTime.UtcNow.Ticks.ToString(); int A = postedfile.FileName.LastIndexOf("."); int length = postedfile.FileName.Length; string extention = postedfile.FileName.Substring(A, length - A); if (System.IO.File.Exists(savepath + FileName + ".jpg")) { System.IO.File.SetAttributes(savepath + FileName + ".jpg", System.IO.FileAttributes.Normal); System.IO.File.Delete(savepath + FileName + ".jpg"); } postedfile.SaveAs(savepath + FileName + ".jpg"); ////Below Code is to Save First Product Image in Product DB Table if (i == 0) { p.Image = "../content/Product_Image/" + ProductID + "/" + FileName + ".jpg"; interfaceobj.UpdateModel(p); interfaceobj.Save(); } //LinqConnection dc = new LinqConnection(); //var UpdateImage = dc.FF_Products.FirstOrDefault(a => a.ID == ProductID); //if (UpdateImage != null) //{ // UpdateImage.Image = ProductID + ".jpg"; // dc.SubmitChanges(); //} // return Json("done", JsonRequestBehavior.AllowGet); } } } return(Json("done", JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public ActionResult GetProductRecordsForEdit() { int Product_Id = Convert.ToInt32(Request.QueryString["Product_Id"]); //Product Main Table// var productrecord = interfaceobj.GetModel().Where(a => a.ID == Product_Id).AsEnumerable(); DataContext dc = new DataContext(); //Category for dropdownlist var catlist = dc.FF_Category; ViewBag.Dropdown_Category = new SelectList(catlist, "ID", "Category"); //Sub Category for dropdownlist var subcatlist = dc.FF_Sub_Category; ViewBag.Dropdown_SubCategory = new SelectList(subcatlist, "ID", "SubCategory"); //Product Variant for dropdownlist var variantlist = dc.FF_Product_Variants; ViewBag.Dropdown_Variant = new SelectList(variantlist, "ID", "Variants_Name", "Select Variant"); VM_Product modal = new VM_Product(); var Product_Variant_Id = ((dc.FF_Product_SubTable.Where(a => a.Product_Id == Product_Id).Count() > 0) ? dc.FF_Product_SubTable.Where(a => a.Product_Id == Product_Id).First().Product_Variant_Id : 0); modal.ID = Product_Id; modal.Category_ID = productrecord.FirstOrDefault().Category_ID; modal.Sub_Category_ID = productrecord.FirstOrDefault().Sub_Category_ID; //modal.Product_Variant_Id = dc.FF_Product_SubTable.FirstOrDefault(a => a.Product_Id == Product_Id).Product_Variant_Id; modal.Product_Variant_Id = ((dc.FF_Product_SubTable.Where(a => a.Product_Id == Product_Id).Count() > 0) ? dc.FF_Product_SubTable.Where(a => a.Product_Id == Product_Id).First().Product_Variant_Id : 0); modal.Brand = productrecord.FirstOrDefault().Brand; modal.Product_Name = productrecord.FirstOrDefault().Product_Name; modal.Product_Code = productrecord.FirstOrDefault().Product_Code; modal.Price = productrecord.FirstOrDefault().Price; modal.Quantity = productrecord.FirstOrDefault().Quantity; modal.Discount = productrecord.FirstOrDefault().Discount; modal.Description = productrecord.FirstOrDefault().Description; modal.ImageCollection = MyHelperClass.GetProduct_Images(Product_Id); if (Product_Variant_Id != 4 && Product_Variant_Id != 0) { modal.VariantCollectionList = dc.FF_Product_SubTable.Where(f => f.Product_Id == Product_Id).Select(s => new VariantCollection { Product_Sub_Table_ID = s.ID, First_Input = (string.IsNullOrEmpty(s.Product_Size) ? (string.IsNullOrEmpty(s.Product_Colour) ? s.Product_Weight : s.Product_Colour) : s.Product_Size), Second_Input = s.Product_Price, Third_Input = s.Product_Quantity, //Size = s.Product_Size, //Colour = s.Product_Colour, //Weight = s.Product_Weight, //Price = s.Product_Price, //Quantity = s.Product_Quantity }).ToList(); } else if (Product_Variant_Id == 4) { modal.VariantCollectionList = dc.FF_Product_SubTable.Where(f => f.Product_Id == Product_Id).Select(s => new VariantCollection { Product_Sub_Table_ID = s.ID, First_Input = s.Product_Size, Second_Input = s.Product_Colour, Third_Input = s.Product_Price, Fourth_Input = s.Product_Quantity //Size = s.Product_Size, //Colour = s.Product_Colour, //Weight = s.Product_Weight, //Price = s.Product_Price, //Quantity = s.Product_Quantity }).ToList(); } return(View("PV_EditProduct", modal)); //return Json(productrecord, JsonRequestBehavior.AllowGet); }