public ActionResult Save(ColorModel obj)
 {
     bool check = true;
     if (Request.IsAuthenticated)
     {
         if (obj.id > 0)
         {
             check = ColorDal.Update(obj);
         }
         else
         {
             check = ColorDal.Create(obj);
         }
         if (check)
         {
             TempData["message"] = "Saved successfully";
         }
         else
         {
             TempData["message"] = "Error while saving data";
         }
         return RedirectToAction("Create", "Color");
     }
     else
     {
         return RedirectToAction("index", "home");
     }
 }
 public ActionResult Create()
 {
     if (Request.IsAuthenticated)
     {
         ViewBag.PageTittle = "Add Color";
         ViewBag.breadCrum = "<a href='/Admin/Color/index'>Category</a> >> Add Color";
         ColorModel obj = new ColorModel();
         return View(obj);
     }
     else
     {
         return RedirectToAction("index", "home");
     }
 }
 public ActionResult Edit(int id)
 {
     if (Request.IsAuthenticated)
     {
         ViewBag.PageTittle = "Edit Color";
         ViewBag.breadCrum = "<a href='/Admin/Color/index'>Color</a> >> Edit Color";
         ColorModel obj = new ColorModel();
         obj = ColorDal.GetById(id);
         return View("Create", obj);
     }
     else
     {
         return RedirectToAction("index", "home");
     }
 }
Exemple #4
0
 public static bool Create(ColorModel obj)
 {
     bool check = true;
     try
     {
         var context = new Ecommerce.DbEntity.ecommerceEntities();
         context.colors.Add(new DbEntity.color { name = obj.name });
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         check = false;
     }
     return check;
 }
Exemple #5
0
        public static List<ColorModel> GetAllColorsByProductId(int productId)
        {
            List<ColorModel> returnObj = new List<ColorModel>();
            //returnObj.Add(new ColorModel { id = 0, name = "Select" });
            var context = new Ecommerce.DbEntity.ecommerceEntities();
            var pricising = context.productpricings.Where(m => m.productid == productId).ToList();
            foreach (var x in pricising)
            {
                var color = new ColorModel();
                color.id = Convert.ToInt32(x.colorId);
                color.IsSelected = true;
                color.LengthId = Convert.ToInt32(x.lengthId);
                color.name = GetById(Convert.ToInt32(x.colorId)).name;
                color.ourpriceangola = Convert.ToDecimal(x.ourpriceangola);
                color.OurPriceDollar = Convert.ToDecimal(x.ourpriceDollar);
                color.OurPriceEuro = Convert.ToDecimal(x.ourpriceeuro);
                color.ourpriceghana = Convert.ToDecimal(x.ourpriceghana);
                color.ourpricenigeria = Convert.ToDecimal(x.ourpricenigeria);
                color.OurPricePound = Convert.ToDecimal(x.ourpricepound);
                color.priceangola = Convert.ToDecimal(x.priceangola);
                color.PriceDollar = Convert.ToDecimal(x.priceDollar);
                color.PriceEuro = Convert.ToDecimal(x.priceeuro);
                color.priceghana = Convert.ToDecimal(x.priceghana);
                color.pricenigeria = Convert.ToDecimal(x.pricenigeria);
                color.PricePound = Convert.ToDecimal(x.pricepound);

                if (returnObj.Count == 0)
                {
                    returnObj.Add(color);
                }
                else
                {
                    if (returnObj.Where(m => m.id == x.colorId).FirstOrDefault() == null)
                    {
                        returnObj.Add(color);
                    }
                }
            }
            return returnObj;
        }
Exemple #6
0
 public static List<ColorModel> GetAllColorsByProductIdForEditProduct(int productId)
 {
     List<ColorModel> returnObj = new List<ColorModel>();
     //returnObj.Add(new ColorModel { id = 0, name = "Select" });
     var context = new Ecommerce.DbEntity.ecommerceEntities();
     var pricising = context.productpricings.Where(m => m.productid == productId).ToList();
     foreach (var x in pricising)
     {
         var color = new ColorModel();
         color.id = Convert.ToInt32(x.colorId);
         color.IsSelected = true;
         color.LengthId = Convert.ToInt32(x.lengthId);
         color.name = GetById(Convert.ToInt32(x.colorId)).name;
         color.ourpriceangola = x.ourpriceangola;
         color.OurPriceDollar = x.ourpriceDollar;
         color.OurPriceEuro = x.ourpriceeuro;
         color.ourpriceghana = x.ourpriceghana;
         color.ourpricenigeria = x.ourpricenigeria;
         color.OurPricePound = x.ourpricepound;
         color.priceangola = x.priceangola;
         color.PriceDollar = x.priceDollar;
         color.PriceEuro = x.priceeuro;
         color.priceghana = x.priceghana;
         color.pricenigeria = x.pricenigeria;
         color.PricePound = x.pricepound;
         returnObj.Add(color);
     }
     return returnObj;
 }
Exemple #7
0
 public static bool Update(ColorModel obj)
 {
     bool check = true;
     try
     {
         var context = new Ecommerce.DbEntity.ecommerceEntities();
         var color = context.colors.Where(m => m.id == obj.id).FirstOrDefault();
         color.name = obj.name;
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         check = false;
     }
     return check;
 }
Exemple #8
0
 public static ColorModel GetById(int id)
 {
     var context = new Ecommerce.DbEntity.ecommerceEntities();
     var col = context.colors.Where(m => m.id == id).FirstOrDefault();
     var color = new ColorModel();
     color.id = col.id;
     color.name = col.name;
     return color;
 }