public ActionResult Edit(UserData user, FormCollection collection) { try { string UserId = user.UserId; string EmailId = user.EmailId; string Password = user.Password; string FirstName = user.FirstName; string LastName = user.LastName; string BillingAddress = user.BillingAddress; string ShippingAddress = user.ShippingAddress; long CardNumber = user.CardNumber; string CardType = user.CardType; DateTime CardExpiryDate = user.CardExpiryDate; long PhoneNumber = user.PhoneNumber; LetsShopImplementation.UpdateUser(user); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult SignUp(UserData UserData, FormCollection collection) { try { string FirstName = UserData.FirstName; string LastName = UserData.LastName; string UserId = UserData.UserId; string Password = UserData.Password; string BillingAddress = UserData.BillingAddress; string ShippingAddress = UserData.ShippingAddress; double CardNumber = UserData.CardNumber; string CardType = UserData.CardType; DateTime CardExpiryDate = UserData.CardExpiryDate; double PhoneNumber = UserData.PhoneNumber; string EmailId = UserData.EmailId; ViewBag.SignUpMessage = LetsShopImplementation.CreateUser(UserId, Password, EmailId); return(View()); } catch (Exception ex) { return(RedirectToAction("ErrorPage", "Product")); } }
/// <summary> /// GET: /Product/ /// </summary> /// <returns></returns> public ActionResult Index(int?page) { List <int> orderidlist = new List <int>(); List <AddToCartModel> cartlist = ShoppingCartImplementation.GetFromCart(@User.Identity.Name); CartAndAllProducts cp = new CartAndAllProducts(); foreach (var x in cartlist) { orderidlist.Add(x.Product.ProductId); } ViewBag.Message = orderidlist; List <Product> productcacheData = new List <Product>(); productcacheData = (List <Product>)cache["ProductData"]; if (productcacheData == null) { cache.Add("ProductData", LetsShopImplementation.GetProducts(), CacheItemPriority.High, null, absolutetime); //productcacheData = (List<Product>)cache["ProductData"]; } List <Product> prodlist = productcacheData; cp.productlist = prodlist; cp.cartlist = cartlist; return(View(cp)); }
public ActionResult Edit(ProductCategoryRelation pcr, int id, HttpPostedFileBase file) { try { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath("~/Images/" + fileName)); pcr.product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + fileName; } pcr.product.ProductId = id; pcr.categories = LetsShopImplementation.GetCategoryIdByName(pcr.categories.CategoryName, pcr.categories.SubCategoryName); pcr.product.CategoryId = pcr.categories.CategoryId; pcr.product.SubCategoryId = pcr.categories.SubCategoryId; LetsShopImplementation.UpdateProduct(pcr.product); //cache.Add("ProductData", LetsShopImplementation.GetProducts(), // CacheItemPriority.High, null, absolutetime); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
/// <summary> /// GET: /Product/ /// </summary> /// <returns></returns> public ActionResult Index(int?page) { List <int> orderidlist = new List <int>(); List <AddToCartModel> cartlist = ShoppingCartImplementation.GetFromCart(@User.Identity.Name); CartAndAllProducts cp = new CartAndAllProducts(); foreach (var x in cartlist) { // orderidlist.Add(x.Product.ProductId); } ViewBag.Message = orderidlist; List <Product> prodlist = LetsShopImplementation.GetProducts(); foreach (var product in prodlist) { var fileName = product.Picture; var dataArray = product.PictureContent; if (dataArray != null && !System.IO.File.Exists(Server.MapPath("~/Images/" + fileName))) { using (FileStream fileStream = new FileStream(Server.MapPath("~/Images/" + fileName), FileMode.Create)) { //var dataArray = artikel.Artikel.Artikel_Afbeelding.Afbeelding.Contents; // Write the data to the file, byte by byte. for (int i = 0; i < dataArray.Length; i++) { fileStream.WriteByte(dataArray[i]); } // Set the stream position to the beginning of the file. fileStream.Seek(0, SeekOrigin.Begin); // Read and verify the data. for (int i = 0; i < fileStream.Length; i++) { if (dataArray[i] != fileStream.ReadByte()) { } } Console.WriteLine("The data was written to {0} " + "and verified.", fileStream.Name); } } product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + fileName; } cp.productlist = prodlist; cp.cartlist = cartlist; return(View(cp)); }
//______________________________________________________________________________________ /// <summary> /// GET: MyAccount/MyOrders /// </summary> /// <returns></returns> public ActionResult MyOrders() { if (Session["usertype"] != null) { return(View(LetsShopImplementation.GetMyOrders(@User.Identity.Name))); } else { return(RedirectToAction("Index", "Home")); } }
//______________________________________________________________________________________ /// <summary> /// GET: MyAccount/OrderDetails/5 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult OrderDetails(int id = 0) { if (Session["usertype"] != null) { return(View(LetsShopImplementation.GetOrderDetails(id))); } else { return(RedirectToAction("Index", "Home")); } }
//______________________________________________________________________________________ /// <summary> /// This method is used to save the transaction status which has been changed from 'Processing' to 'Shipped'. /// </summary> /// <param name="OrderId"></param> /// <param name="UserId"></param> /// <param name="TransactionStatus"></param> /// <returns></returns> public ActionResult SaveChanges(int OrderId, string UserId, string TransactionStatus) { if (TransactionStatus == "Shipped") { LetsShopImplementation.OrderStatus(OrderId, UserId, TransactionStatus); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }
public ActionResult CancelOrder(int id, string userid) { if (Session["usertype"] != null) { string result = LetsShopImplementation.CancelMyOrder(id, @User.Identity.Name); return(RedirectToAction("MyOrders", "MyAccount")); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Browse(string Category, int Max = 0, int Min = 0) { try { List <Product> products = LetsShopImplementation.PriceFilter(Category, Max, Min); return(View(products)); } catch (Exception ex) { return(View()); } }
/// <summary> /// GET: /Product/Search?Category=Books&SubCategory=Fiction /// </summary> /// <param name="Category"></param> /// <param name="SubCategory"></param> /// <returns></returns> public ActionResult Search(string Category, string SubCategory) { try { List <Product> products = LetsShopImplementation.GetProductsBySubCategoryName(Category, SubCategory); return(View(products)); } catch (Exception ex) { return(RedirectToAction("ErrorPage", "Product")); } }
/// <summary> /// GET: /MyAccount/ /// </summary> /// <returns></returns> public ActionResult Index() { if (Session["usertype"] != null) // If some user is logged in { string LoggedInUser = @User.Identity.Name; // the string "LoggedInUser" wil contain the username of the user who logs in! return(View(LetsShopImplementation.GetUserDetailsByUserName(LoggedInUser))); } else { return(RedirectToAction("Index", "Home")); } }
public void CreateUserTest() { string UserId = string.Empty; // TODO: Initialize to an appropriate value string Password = string.Empty; // TODO: Initialize to an appropriate value string EmailId = string.Empty; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = LetsShopImplementation.CreateUser(UserId, Password, EmailId); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public void NegativeDeleteProductTest() { Product product = new Product(); // TODO: Initialize to an appropriate value int id = 56; string expected = "Product Id doesnot exists"; // TODO: Initialize to an appropriate value string actual; actual = LetsShopImplementation.DeleteProduct(id); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public ActionResult Browse(string Category, int Max = 0, int Min = 0) { try { List <Product> products = LetsShopImplementation.PriceFilter(Category, Max, Min); return(View(products)); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy"); return(View()); } }
public ActionResult CheckOut(CheckOutModel checkout) { try { checkout.userdata.UserId = @User.Identity.Name; ViewBag.checkOutMessage = LetsShopImplementation.PlaceOrder(checkout); ShoppingCartImplementation.EmptyCart(@User.Identity.Name); return(View()); } catch (Exception ex) { return(View()); } }
public ActionResult SecurityQuestion(UserData userdata, FormCollection fc1) { UserCredentials usercr = new UserCredentials(); usercr = LetsShopImplementation.LoginAfterForgotPassword(userdata.UserId, userdata.SecurityAnswer); if (usercr.Password == "") { ViewBag.message = "Security answer does not match"; return(View(LetsShopImplementation.ForgotPassword(userdata.UserId))); } else { Login(usercr, fc1); return(RedirectToAction("Index", "Home")); } }
public ActionResult Delete(int id, Product product) { try { LetsShopImplementation.DeleteProduct(id); //cache.Add("ProductData", LetsShopImplementation.GetProducts(), // CacheItemPriority.High, null, absolutetime); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
/// <summary> /// GET: /Product/Search?Category=Books&SubCategory=Fiction /// </summary> /// <param name="Category"></param> /// <param name="SubCategory"></param> /// <returns></returns> public ActionResult Search(string Category, string SubCategory) { try { List <Product> products = LetsShopImplementation.GetProductsBySubCategoryName(Category, SubCategory); return(View(products)); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy"); if (rethrow) { throw; } return(RedirectToAction("ErrorPage", "Product")); } }
/// <summary> /// GET: /Orders/ /// </summary> /// <returns></returns> public ActionResult Index() { if (Session["usertype"] != null) // If some user is logged in { if (Session["usertype"].ToString() == "Admin") { return(View(LetsShopImplementation.GetAllOrders())); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index", "Home")); } }
//______________________________________________________________________________________ /// <summary> /// GET: /Product/Delete/5 /// </summary> /// <param name="id"></param> /// <returns></returns> /// public ActionResult Delete(int id) { if (Session["usertype"] != null) { if (Session["usertype"].ToString() == "Admin") { return(View(LetsShopImplementation.GetProduct(id))); } else { return(RedirectToAction("Index", "Product")); } } else { return(RedirectToAction("Index", "Product")); } }
//______________________________________________________________________________________ /// <summary> /// Product/CheckOut /// </summary> /// <returns></returns> public ActionResult CheckOut() { try { if (Session["usertype"] != null) { string LoggedInUser = @User.Identity.Name; return(View(LetsShopImplementation.GetCheckOutDetails(LoggedInUser))); } else { return(RedirectToAction("Index", "Product")); } } catch (Exception ex) { return(RedirectToAction("Index", "Product")); } }
public string Login(UserCredentials UserCredentials, FormCollection collection) { try { ViewBag.LoginMessage = LetsShopImplementation.ValidateUser(UserCredentials.UserId, UserCredentials.Password); if ((ViewBag.LoginMessage == "Admin logged in successfully") || (ViewBag.LoginMessage == "Guest logged in successfully")) { string type = ViewBag.LoginMessage; type = type.Split(' ')[0]; Session["usertype"] = type; FormsAuthentication.SetAuthCookie(UserCredentials.UserId, false); } return(ViewBag.LoginMessage); } catch { return("The network is down. Please try some time later."); } }
public ActionResult CheckOut(CheckOutModel checkout) { try { checkout.userdata.UserId = @User.Identity.Name; ViewBag.checkOutMessage = LetsShopImplementation.PlaceOrder(checkout); ShoppingCartImplementation.EmptyCart(@User.Identity.Name); return(View()); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy"); if (rethrow) { throw; } return(View()); } }
public void CreateProductTest() { Product product = new Product() { ProductName = "Fridge", ProductDescription = "home appliance", SubCategoryId = 3, Price = 6000, Colour = "red", Size = "165 lts", UnitsInStock = 5, StockAvailability = 1, Picture = null }; string expected = "Product Created Successfully"; string actual; actual = LetsShopImplementation.CreateProduct(product); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public ActionResult Delete(int id, Product product) { try { LetsShopImplementation.DeleteProduct(id); cache.Add("ProductData", LetsShopImplementation.GetProducts(), CacheItemPriority.High, null, absolutetime); return(RedirectToAction("Index")); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy"); if (rethrow) { throw; } return(View()); } }
public List<Product> GetProductData(out string cacheStatus) { cacheProductData = EnterpriseLibraryContainer.Current.GetInstance<ICacheManager>(); listProducts = (List<Product>)cacheProductData["ProductDataCache"]; cacheStatus = "Employee Information is Retrived from Cache"; LetsShopImplementation ls = new LetsShopImplementation(); CacheFlag = true; if (listProducts == null) { //Database _db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LetsShopConnection"); //listProducts = LetsShopImplementation ls = new LetsShopImplementation(); listProducts = ls.GetProducts(); AbsoluteTime CacheExpirationTime = new AbsoluteTime(new TimeSpan(1, 0, 0)); cacheProductData.Add("ProductDataCache", listProducts, CacheItemPriority.High, null, new ICacheItemExpiration[] { CacheExpirationTime }); cacheStatus = "Product Info is Added in cache"; CacheFlag = false; } return listProducts; }
//______________________________________________________________________________________ /// <summary> /// GET: MyAccount/ExportMyOrders [Exports all users to an Excel File] /// </summary> /// <returns></returns> public ActionResult ExportMyOrders() { try { GridView gv = new GridView(); gv.DataSource = LetsShopImplementation.GetMyOrders(@User.Identity.Name); gv.DataBind(); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=MyOrders.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gv.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } catch (Exception) { return(RedirectToAction("ErrorPage", "Product")); } return(View("Index")); }
//______________________________________________________________________________________ /// <summary> /// GET: /Product/Details/5 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Details(int id) { var productCatRelation = LetsShopImplementation.GetProduct(id); var product = productCatRelation.product; var dataArray = product.PictureContent; var fileName = product.Picture; if (!System.IO.File.Exists(Server.MapPath("~/Images/" + fileName))) { using (FileStream fileStream = new FileStream(Server.MapPath("~/Images/" + fileName), FileMode.Create)) { //var dataArray = artikel.Artikel.Artikel_Afbeelding.Afbeelding.Contents; // Write the data to the file, byte by byte. for (int i = 0; i < dataArray.Length; i++) { fileStream.WriteByte(dataArray[i]); } // Set the stream position to the beginning of the file. fileStream.Seek(0, SeekOrigin.Begin); // Read and verify the data. for (int i = 0; i < fileStream.Length; i++) { if (dataArray[i] != fileStream.ReadByte()) { } } Console.WriteLine("The data was written to {0} " + "and verified.", fileStream.Name); } } product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + fileName; return(View(productCatRelation)); }
public ActionResult CreateProduct(ProductCategoryRelation pcr, HttpPostedFileBase file) { try { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath("~/Images/" + fileName)); pcr.product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + fileName; } else { pcr.product.Picture = WebConfigurationManager.AppSettings["ImageUpload"] + "defaultimage.jpg"; } pcr.categories = LetsShopImplementation.GetCategoryIdByName(pcr.categories.CategoryName, pcr.categories.SubCategoryName); pcr.product.CategoryId = pcr.categories.CategoryId; pcr.product.SubCategoryId = pcr.categories.SubCategoryId; LetsShopImplementation.CreateProduct(pcr.product); cache.Add("ProductData", LetsShopImplementation.GetProducts(), CacheItemPriority.High, null, absolutetime); return(RedirectToAction("Index")); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy"); if (rethrow) { throw; } return(View()); } }