public ActionResult Add(ProductCategoryModel pcm) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; PriceDataService dataService = new PriceDataService(); try { dataService.InsertProductCategory(pcm); return RedirectToAction("Edit", "Price"); } catch (Exception ex) { throw ex; } finally { dataService = null; } }
public void UpdateProductCategory(ProductCategoryModel pcm) { try { ProductCategory table = new ProductCategory(); using (VenturadaDataContext vdc = new VenturadaDataContext()) { table = vdc.ProductCategories.Single(a => a.ProductCategoryId == pcm.ProductCategoryId); table.ProductCategoryId = pcm.ProductCategoryId; table.ProductCategory1 = pcm.ProductCategory; vdc.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public void InsertProductCategory(ProductCategoryModel pcm) { try { using (VenturadaDataContext vdc = new VenturadaDataContext()) { ProductCategory receivedPM = new ProductCategory(); receivedPM.ProductCategory1 = pcm.ProductCategory; vdc.ProductCategories.InsertOnSubmit(receivedPM); vdc.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public ProductCategoryModel GetProductCategoryModelByProductCategoryId(int productCategoryId) { ProductCategoryModel model = new ProductCategoryModel(); try { using (VenturadaDataContext vdc = new VenturadaDataContext()) { var list = from p in vdc.ProductCategories.ToList() where p.ProductCategoryId == productCategoryId select p; if (list != null) { model.ProductCategoryId = list.FirstOrDefault().ProductCategoryId; model.ProductCategory = list.FirstOrDefault().ProductCategory1; } return model; } } catch (Exception ex) { throw ex; } }
public List<ProductCategoryModel> GenerateProductCategoryModel() { List<ProductCategoryModel> modelList = new List<ProductCategoryModel>(); ProductCategoryModel model = new ProductCategoryModel(); ProductHeaderModel model2 = new ProductHeaderModel(); try { using (VenturadaDataContext vdc = new VenturadaDataContext()) { var list = from p in vdc.ProductCategories.ToList() orderby p.ProductCategoryId ascending select p; foreach (var item in list) { model = new ProductCategoryModel(); model.ProductCategoryId = item.ProductCategoryId; model.ProductCategory = item.ProductCategory1; //model.ProductHeaderModel = GetProductHeaderByProductCategoryId(item.ProductCategoryId); model.PriceListModel = GetPriceListByProductCategoryId(item.ProductCategoryId); modelList.Add(model); } return modelList; } } catch (Exception ex) { throw ex; } }
public ActionResult EditCategory(int productCategoryId) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; PriceDataService dataService = new PriceDataService(); ProductCategoryModel model = new ProductCategoryModel(); try { model = dataService.GetProductCategoryModelByProductCategoryId(productCategoryId); return View(model); } catch (Exception ex) { throw ex; } finally { dataService = null; } }