Example #1
0
        public void InsertPriceList(PriceListModel model)
        {
            try
            {
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {
                    PriceList table = new PriceList();
                    table.ProductCategoryId = model.ProductCategoryId;
                    table.ProductName = model.ProductName;
                    table.ProductDescription = model.ProductDescription;
                    table.Price = model.Price;

                    vdc.PriceLists.InsertOnSubmit(table);
                    vdc.SubmitChanges();
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #2
0
        public void UpdatePriceList(PriceListModel model)
        {
            try
            {
                PriceList table = new PriceList();
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {
                    table = vdc.PriceLists.Single(a => a.PriceListId == model.PriceListId);
                    table.ProductDescription = model.ProductDescription;
                    table.ProductName = model.ProductName;
                    table.Price = model.Price;
                    vdc.SubmitChanges();
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #3
0
        public List<PriceListModel> GetPriceListByProductCategoryId(int productCategoryId)
        {
            List<PriceListModel> modelList = new List<PriceListModel>();
            PriceListModel model = new PriceListModel();
            try
            {
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {
                    var list = from p in vdc.PriceLists.ToList()
                               where p.ProductCategoryId == productCategoryId
                               orderby p.PriceListId ascending
                               select p;

                    foreach (var item in list)
                    {
                        model = new PriceListModel();
                        model.PriceListId = item.PriceListId;
                        model.ProductCategoryId = item.ProductCategoryId;
                        model.ProductName = item.ProductName;
                        model.ProductDescription = item.ProductDescription;
                        model.Price = item.Price;
                        modelList.Add(model);
                    }

                    return modelList;

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #4
0
        public PriceListModel GetPriceListById(int priceListId)
        {
            PriceListModel model = new PriceListModel();
            try
            {
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {
                    var list = from p in vdc.PriceLists.ToList()
                               where p.PriceListId == priceListId
                               select p;
                    if (list != null)
                    {
                        model.PriceListId = list.FirstOrDefault().PriceListId;
                        model.ProductCategoryId = list.FirstOrDefault().ProductCategoryId;
                        model.ProductName = list.FirstOrDefault().ProductName;
                        model.ProductDescription = list.FirstOrDefault().ProductDescription;
                        model.Price = list.FirstOrDefault().Price;
                    }

                    return model;
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #5
0
        public ActionResult EditPrice(PriceListModel plm)
        {
            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();
            PriceListModel model = new PriceListModel();
            try
            {
                if (ModelState.IsValid)
                {
                    model.PriceListId = plm.PriceListId;
                    model.ProductName = plm.ProductName;
                    model.ProductDescription = plm.ProductDescription;
                    model.Price = plm.Price;
                    dataService.UpdatePriceList(model);
                    return RedirectToAction("Edit", "Price");
                }
                else
                {
                    return View(plm);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dataService = null;
            }
        }
Example #6
0
        public ActionResult EditPrice(int priceListId)
        {
            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();
            PriceListModel model = new PriceListModel();
            try
            {
                model = dataService.GetPriceListById(priceListId);
                return View(model);
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dataService = null;
            }
        }
Example #7
0
        public ActionResult AddPrice(PriceListModel 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.InsertPriceList(pcm);
                return RedirectToAction("Edit", "Price");
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dataService = null;
            }
        }