Ejemplo n.º 1
0
        public ProductsMainModel GenerateProductsMainModel()
        {
            ProductsMainModel pmm = new ProductsMainModel();
            try
            {
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {
                    var productsMain = from p in vdc.ProductsMains.ToList()
                                  orderby p.ProductsMainId ascending
                                  select p;
                    if (productsMain.FirstOrDefault() != null)
                    {
                        pmm = new ProductsMainModel();
                        pmm.ProductsMainId = productsMain.FirstOrDefault().ProductsMainId;
                        pmm.ImageURLString = productsMain.FirstOrDefault().ImageURLString;
                        pmm.ProductMainParagraph = productsMain.FirstOrDefault().ProductMainParagraph;
                        pmm.ProductSubParagraph = productsMain.FirstOrDefault().ProductSubParagraph;
                        pmm.ProductMainParagraphTitle = productsMain.FirstOrDefault().ProductMainParagraphTitle;
                        pmm.ProductSubParagraphTitle = productsMain.FirstOrDefault().ProductSubParagraphTitle;
                    }

                    return pmm;
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditProductsMain(ProductsMainModel aum)
        {
            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;
            ProductsDataService auDS = new ProductsDataService();
            string id = (string)Request.Form["edit_ProductsMainId"];
            try
            {
                if (ModelState.IsValid)
                {
                    aum.ProductsMainId = int.Parse(id);
                    auDS.UpdateProductsMain(aum);
                    return RedirectToAction("Edit", "Products");
                }
                else
                {
                    aum = new ProductsMainModel();
                    aum.ProductsMainId = int.Parse(id);
                    return View(aum);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                auDS = null;
            }
        }
Ejemplo n.º 3
0
        public void UpdateProductsMain(ProductsMainModel aum)
        {
            try
            {
                ProductsMain au = new ProductsMain();
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {
                    au = vdc.ProductsMains.Single(a => a.ProductsMainId == aum.ProductsMainId);
                    au.ProductsMainId = aum.ProductsMainId;
                    au.ProductMainParagraph = aum.ProductMainParagraph;
                    au.ProductSubParagraph = aum.ProductSubParagraph;
                    au.ProductMainParagraphTitle = aum.ProductMainParagraphTitle;
                    au.ProductSubParagraphTitle = aum.ProductSubParagraphTitle;
                    vdc.SubmitChanges();
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }