public ActionResult ViewAllProducts() { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <product, Models.product> map = new PRFancyAutoMapper <product, Models.product>(); List <Models.product> modellstProduct = new List <Models.product>(); List <product> lstProduct; try { lstProduct = dal.GetAllProduct(); foreach (var item in lstProduct) { modellstProduct.Add(map.Translate(item)); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } return(View(modellstProduct)); }
public ActionResult ViewAllCategory() { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <category, Models.Category> map = new PRFancyAutoMapper <category, Models.Category>(); List <Models.Category> modellstCategory = new List <Models.Category>(); List <category> lstCategory; try { lstCategory = dal.GetCategories(); foreach (var item in lstCategory) { modellstCategory.Add(map.Translate(item)); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } return(View(modellstCategory)); }
public ActionResult EditImage(string productId) { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <productImage, Models.ProductImage> map = new PRFancyAutoMapper <productImage, Models.ProductImage>(); try { productImage obj = dal.GetProductImage(productId); Models.ProductImage modObj = map.Translate(obj); return(View(map.Translate(obj))); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public JsonResult GetProductsByCategory(string categoryId) { PRFancyRepository dal = new PRFancyRepository(); List <product> lstProduct = dal.GetProductsByCategory(categoryId); PRFancyAutoMapper <product, Models.product> map = new PRFancyAutoMapper <product, Models.product>(); List <Models.product> lstModelProduct = new List <Models.product>(); foreach (var item in lstProduct) { lstModelProduct.Add(map.Translate(item)); } return(Json(lstModelProduct)); }
public ActionResult ProductDetails(string productId) { PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <product, Models.product> map = new PRFancyAutoMapper <product, Models.product>(); try { return(View(map.Translate(dal.GetProduct(productId)))); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult ImageHome() { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <productImage, Models.ProductImage> map = new PRFancyAutoMapper <productImage, Models.ProductImage>(); List <productImage> lstproductImages; List <Models.ProductImage> lstModelImages = new List <Models.ProductImage>(); try { lstproductImages = dal.GetProductImages(); foreach (var item in lstproductImages) { lstModelImages.Add(map.Translate(item)); } int i = 0; foreach (var item in lstModelImages) { if (lstproductImages[i].productImage1 != null) { item.Image1 = ConvertToImage(item.productImage1); } if (lstproductImages[i].productImage2 != null) { item.Image2 = ConvertToImage(item.productImage2); } if (lstproductImages[i].productImage3 != null) { item.Image3 = ConvertToImage(item.productImage3); } if (lstproductImages[i].productImage4 != null) { item.Image4 = ConvertToImage(item.productImage4); } ++i; } return(View(lstModelImages)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult SaveDeleteCategory(Models.Category category) { PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <Models.Category, category> map = new PRFancyAutoMapper <Models.Category, category>(); try { if (dal.DeleteCategory(map.Translate(category))) { return(RedirectToAction("ViewAllCategory")); } return(View("Error")); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult SaveDeleteProduct(Models.product product) { PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <Models.product, product> map = new PRFancyAutoMapper <Models.product, product>(); try { if (dal.DeleteProduct(map.Translate(product))) { return(RedirectToAction("ViewAllProducts")); } return(View("Error")); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult DeleteCategory(string categoryId) { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <category, Models.Category> map = new PRFancyAutoMapper <category, Models.Category>(); try { var categoryObj = dal.GetCategory(categoryId); return(View(map.Translate(categoryObj))); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult AfterLogin(Models.user user) { PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <Models.user, user> map = new PRFancyAutoMapper <Models.user, user>(); try { if (dal.ValidateLogin(map.Translate(user))) { Session["user"] = user.Username; return(Redirect("/Admin/AdminHome?user="******"Login", user)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult DeleteProduct(string productId) { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <product, Models.product> map = new PRFancyAutoMapper <product, Models.product>(); try { ViewBag.lstCategory = dal.GetCategories(); var prodObj = dal.GetProduct(productId); return(View(map.Translate(prodObj))); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }