public ActionResult Edit() { Company company = new Company(); BusinessLogicHandler myHandler = new BusinessLogicHandler(); company = myHandler.GetCompanyDetail(); return View(company); }
public ActionResult ExportYearToPDF() { #region Prep Utilities BusinessLogicHandler myHandler = new BusinessLogicHandler(); RangeViewModel model = new RangeViewModel(); model = (RangeViewModel)Session["yearly"]; #endregion #region Push Company nfo model.company = new Company(); model.company = myHandler.GetCompanyDetail(); #endregion return new ViewAsPdf(model); }
public async Task<ActionResult> Receipt(int? IID) { List<CartItem> myItems = new List<CartItem>(); myItems = (List<CartItem>)Session["myItems"]; ProductViewModel model = new ProductViewModel(); myHandler = new BusinessLogicHandler(); model = (ProductViewModel)Session["deliverData"]; #region Get Cart Items List<Book> ifBooks = new List<Book>(); List<Technology> ifGadget = new List<Technology>(); foreach (var item in myItems) { if (myHandler.CheckProductType(item.ProductID)) { Book book = new Book(); book = myHandler.GetBook(item.ProductID); ifBooks.Add(book); } else { Technology gadget = new Technology(); gadget = myHandler.GetTechnologyDetails(item.ProductID); ifGadget.Add(gadget); } //try //{ // Book book = new Book(); // book = myHandler.GetBook(item.ProductID); // ifBooks.Add(book); //} //catch //{ // Technology gadget = new Technology(); // gadget = myHandler.GetTechnologyDetails(item.ProductID); // ifGadget.Add(gadget); //} } model.allTechnology = ifGadget; model.allBook = ifBooks; model.allCartItem = myItems; #endregion #region Push User Details string userName = User.Identity.GetUserName(); ApplicationDbContext dataSocket = new ApplicationDbContext(); UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket); userMgr = new ApplicationUserManager(myStore); var user = userMgr.FindByEmail(userName); model.UserDetails = new ProvideUser(); model.UserDetails.Address = user.Address; model.UserDetails.email = user.Email; model.UserDetails.PhoneNumber = user.PhoneNumber; CustomerContext customer = new CustomerContext(); Customer thisCust = new Customer(); thisCust = customer.Customers.FirstOrDefault(cust => cust.User_Id == user.Id); model.UserDetails.LName = thisCust.LastName; model.UserDetails.Name = thisCust.FirstName; #endregion #region Push Invoice nfo model.recieptData = new Invoice(); model.recieptData = myHandler.GetInvoice(IID.GetValueOrDefault()); #endregion #region Push Company nfo myHandler = new BusinessLogicHandler(); model.company = new Company(); model.company = myHandler.GetCompanyDetail(); #endregion #region Push Delivery nfo Delivery shipping = new Delivery(); myHandler = new BusinessLogicHandler(); shipping = myHandler.GetDeliveryDetails(model.recieptData.DeliveryServiceID); model.deliveryHelper.DeliveryServiceName = shipping.ServiceName; model.deliveryHelper.DeliveryServicePrice = shipping.Price; model.deliveryHelper.DeliveryServiceType = shipping.ServiceType; #endregion #region Calculate List<ProductViewModel.CartHelper> itemList = new List<ProductViewModel.CartHelper>(); ProductViewModel.CartHelper cartHelp; if (myItems != null) { if (ifBooks != null) { var revised = from rev in ifBooks join item in myItems on rev.ProductID equals item.ProductID where rev.ProductID == item.ProductID select new { rev.ProductID, rev.SellingPrice, item.Quantity, item.CartItemID }; foreach (var ite in revised) { cartHelp = new ProductViewModel.CartHelper(); cartHelp.ProductID = ite.ProductID; cartHelp.CartItemID = ite.CartItemID; cartHelp.TotalPerItem = (ite.SellingPrice * ite.Quantity); itemList.Add(cartHelp); } } } if (myItems != null) { if (ifGadget != null) { var revised = from rev in ifGadget join item in myItems on rev.ProductID equals item.ProductID where rev.ProductID == item.ProductID select new { rev.ProductID, rev.SellingPrice, item.Quantity, item.CartItemID }; foreach (var ite in revised) { cartHelp = new ProductViewModel.CartHelper(); cartHelp.ProductID = ite.ProductID; cartHelp.CartItemID = ite.CartItemID; cartHelp.TotalPerItem = (ite.SellingPrice * ite.Quantity); itemList.Add(cartHelp); } } } double cartTotal = Convert.ToDouble(Session["cartTotal"].ToString()); cartTotal = cartTotal / 100; myHandler = new BusinessLogicHandler(); List<Company> company = myHandler.GetCompanyDetails(); double vat = 0; cartTotal += Convert.ToDouble(model.deliveryHelper.DeliveryServicePrice); foreach (var item in company) { vat = item.VATPercentage; } vat = vat + 1; double subTotal = cartTotal / vat; double vatAmount = cartTotal - subTotal; ProductViewModel.CartConclude finishing = new ProductViewModel.CartConclude(); finishing.CartTotal = cartTotal; finishing.VatAddedTotal = vatAmount; finishing.SubTotal = subTotal; model.ItsA_wrap = new List<ProductViewModel.CartConclude>(); model.ItsA_wrap.Add(finishing); model.secureCart = itemList; #endregion #region Clear the cart foreach (var item in itemList) { myHandler = new BusinessLogicHandler(); myHandler.DeleteCartItem(item.CartItemID); } #endregion #region Clear SESSION Session["myItems"] = null; Session["cartTotal"] = (double) await GetCartTotal(user.Carts.CartID); #endregion #region Prep for exporting to PDF Session["pdf"] = model; #endregion return View(model); }
public ActionResult ExportToPDF( DateTime? Dfrom, DateTime? Dto, string type) { #region Prep Utilities BusinessLogicHandler myHandler = new BusinessLogicHandler(); RangeViewModel model = new RangeViewModel(); model = (RangeViewModel)Session["xcd"]; #endregion #region Push Company nfo model.company = new Company(); model.company = myHandler.GetCompanyDetail(); #endregion return new ViewAsPdf(model); }