private MenuPathMain getMainMenuPath(ShopVM shopCreate) { MenuPathMain mpm = MenuPathMainBiz.Find(shopCreate.MenuPathMainId); mpm.IsNullThrowException("Menu Path Not Found."); return(mpm); }
public AdminTools() { InitializeComponent(); shopVM = ShopVM.Instance; DataContext = shopVM; //Default values for the properties, with the goal of displaying the needed message //in the textboxes, instructing the user of what they should type in the boxes ProductID.Text = "Angiv ProduktID"; ProductName.Text = "Angiv Produktnavn"; Category.Text = "Angiv Kategori"; ProductDescription.Text = "Angiv Beskrivelse"; ProductImage.Text = "Indsæt Link Til Billede"; ProductPrice.Text = "Angiv Pris"; AmountInStock.Text = "Angiv Antal På Lager"; ShippingPrice.Text = "Angiv Fragtpris"; Size.Text = "Angiv Størrelse"; DiscountPrice.Text = "Angiv Tilbudspris"; txb_ProductName.Text = "Angiv Produktnavn"; txb_ProductID.Text = "Angiv ProduktID"; txb_ProductDescription.Text = "Angiv Beskrivelse"; txb_AmountInStock.Text = "Angiv Antal På Lager"; txb_ProductImage.Text = "Indsæt Link Til Billede"; txb_Price.Text = "Angiv Pris"; txb_DiscountPrice.Text = "Angiv Tilbudspris"; txb_ShippingPrice.Text = "Angiv Fragtpris"; ListInCombobox(); }
public void GetShopContent(ShopVM shop) { var allResults = db.Products.Where(p => (!shop.HCategoryId.HasValue || shop.HCategoryId.Value == p.HCategoryId) && (!shop.VCategoryId.HasValue || shop.VCategoryId.Value == p.VCategoryId)); int rc = allResults.Count(); shop.PagesCount = rc / shop.PageSizeId + (rc % shop.PageSizeId > 0 ? 1 : 0); switch (shop.SortById) { case 1: allResults = allResults.OrderBy(i => i.Name); break; case 2: allResults = allResults.OrderBy(i => i.Price); break; } int toSkip = (shop.Page - 1) * shop.PageSizeId; var page = allResults.Skip <Product>(toSkip).Take(shop.PageSizeId); shop.Products = page.ProjectToList <ShopItemVM>(_map.ConfigurationProvider); shop.HCategory = db.HCategories.Select(c => new SelectListItem() { Text = c.CategoryName, Value = c.HCategoryId.ToString() }).ToList(); shop.VCategory = db.VCategories.Select(c => new SelectListItem() { Text = c.CategoryName, Value = c.VCategoryId.ToString() }).ToList(); }
public ActionResult Edit(ShopVM vm) { if (!ModelState.IsValid) { return(PartialView(vm)); } else { float[] fee = new float[5]; fee[vm.Entity.PayMethod1.GetHashCode()] += vm.Entity.Fee1; fee[vm.Entity.PayMethod2.GetHashCode()] += vm.Entity.Fee2; fee[vm.Entity.PayMethod3.GetHashCode()] += vm.Entity.Fee3; fee[vm.Entity.PayMethod4.GetHashCode()] += vm.Entity.Fee4; fee[vm.Entity.PayMethod5.GetHashCode()] += vm.Entity.Fee5; vm.Entity.XjFee = fee[0]; vm.Entity.WxFee = fee[1]; vm.Entity.SkFee = fee[2]; vm.Entity.ZfbFee = fee[3]; vm.Entity.WXZZFee = vm.Entity.WxFee * 0.001f; vm.Entity.SumFee = vm.Entity.XjFee + vm.Entity.WxFee + vm.Entity.SkFee + vm.Entity.ZfbFee - vm.Entity.WXZZFee; vm.DoEdit(); if (!ModelState.IsValid) { vm.DoReInit(); return(PartialView(vm)); } else { return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID)); } } }
public ActionResult List() { ShopVM shop = new ShopVM(); _ps.GetShopContent(shop); return(PartialView(shop)); }
public ActionResult SubmitShop() { ShopVM S = new ShopVM(); ShopsM objS = new ShopsM(); objS.City = Request.Form["shop.City"].ToString(); objS.Address = Request.Form["shop.Address"].ToString(); objS.Phone = Request.Form["shop.Phone"].ToString(); objS.Week_days = Request.Form["shop.Week_days"].ToString(); objS.Week_end = Request.Form["shop.Week_end"].ToString(); DataLayer dal2 = new DataLayer(); // checking if the entered data is valid if (ModelState.IsValid) { // add the data to DB List <ShopsM> objCustomers = (from x in dal2.Shops select x).ToList <ShopsM>(); objS.ID = (objCustomers.Count + 1).ToString(); dal2.Shops.Add(objS); dal2.SaveChanges(); S.Shop = new ShopsM(); } else { S.Shop = objS; } S.Shops = dal2.Shops.ToList <ShopsM>(); return(View("Shops_view", S)); }
public ShopVM Setup_To_Create_Shop_Get(string returnUrl, string menuPathMainId) { menuPathMainId.IsNullOrWhiteSpaceThrowException("No Menu Path"); UserId.IsNullOrWhiteSpaceThrowException("You must be logged in to continue."); decimal ratePerMonth = getShopRatePerMonth(); int noOfMonths = 1; decimal totalAmount = ratePerMonth * noOfMonths; AddressStringWithNames customerAddress = getDefaultCustomerAddress(); MenuPathMain mpm = MenuPathMainBiz.Find(menuPathMainId); mpm.IsNullThrowException("Menu Path not found"); CashDistributionEngine cashDistributionEnginge = get_CashDistributionEngineAndCheckBalance(totalAmount, true); string explaintion = string.Format("{0}. All your products will be collected and will be shown in your shop. Note, every shop must have a unique name and will be created in its own area. This shop will be created in: ", cashDistributionEnginge.Message); List <string> shopNames = getShopNamesForCurrUser(); string shopName = getAUniqueNameForShop(); ShopVM shopCreate = new ShopVM("", shopName, explaintion, noOfMonths, ratePerMonth, returnUrl, shopNames, mpm, customerAddress); return(shopCreate); }
public ActionResult Index() { ShopVM shop = new ShopVM(); _ps.GetShopContent(shop); FixPrices(shop); return(View(shop)); }
public ActionResult Shop() { ItemBL itemBL = new ItemBL(); ShopVM shopVM = new ShopVM(); shopVM.shop = itemBL.GetItems(); return(View(shopVM)); }
// contact page public ActionResult Contact() { // shop is list of Lists of weights and mechines DataLayer dal = new DataLayer(); List <ShopsM> sList = (from x in dal.Shops select x).ToList <ShopsM>(); ShopVM shop = new ShopVM(); shop.Shops = sList; return(View(shop)); }
//view shops and add a new shop page public ActionResult Shops_view() { // get the shop list from DB DataLayer dal1 = new DataLayer(); List <ShopsM> Sho = dal1.Shops.ToList <ShopsM>(); ShopVM sho = new ShopVM(); sho.Shop = new ShopsM(); sho.Shops = Sho; return(View(sho)); }
private void FixPrices(ShopVM shop) { if (Session["IsBP"] == null || !(bool)Session["IsBP"]) { return; } foreach (var good in shop.Products) { good.Price = good.Price * 0.77M; } }
private static decimal getTotalPayment(ShopVM shopCreate) { if (shopCreate.NoOfMonths == 0) { throw new Exception("No of months is zero"); } //see if User has the money to do what they want. decimal paymentAmount = MenuPathMain.Payment_To_Buy_Shop() * shopCreate.NoOfMonths; return(paymentAmount); }
public Frontpage() { InitializeComponent(); shopVM = ShopVM.Instance; this.DataContext = shopVM; if (shopVM.ListOfProducts == null)// Sets the itemsource again to make sure it is binded to the list "ListOfProducts" in "ShopVM" after it has been populated { shopVM.PopulateList(); } ShopListBox.ItemsSource = shopVM.ListOfProducts; }
public ActionResult DeleteItem(int id) { ItemBL itemBL = new ItemBL(); List <Item> itemList = itemBL.GetItems(); Item item = itemList.Where(u => u.ItemId == id).Single(); itemBL.DeleteItem(item); ShopVM shopVM = new ShopVM(); shopVM.shop = itemBL.GetItems(); return(RedirectToAction("Shop", "Home", shopVM)); }
private static Product setup_Product_For_Shop(ShopVM shopCreate, Owner userOwner) { //now create the shop Product product = new Product(); product.Name = shopCreate.ShopName; product.OwnerId = userOwner.Id; product.ShopExpiryDate.Date = DateTime.Now.AddMonths(shopCreate.NoOfMonths); if (product.BuySellDocs.IsNull()) { product.BuySellDocs = new List <BuySellDoc>(); } product.MainMenuIdForShop = shopCreate.MenuPathMainId; return(product); }
public ShopVM Setup_Shop_For_Edit_Get(string returnUrl, string productId) { productId.IsNullOrWhiteSpaceThrowException("productId"); returnUrl.IsNullOrWhiteSpaceThrowException("returnUrl"); //locate the shop Product product = ProductBiz.Find(productId); product.IsNullThrowException("product"); //now we have the shop... MenuPathMain menuPathMain = product.MenuPathMains_Fixed.FirstOrDefault(); menuPathMain.IsNullThrowException("menuPathMain"); string menuPathMainId = menuPathMain.Id; menuPathMainId.IsNullOrWhiteSpaceThrowException("menuPathMainId"); List <string> shopNames = getShopNamesForCurrUser(); int noOfMonths = 1; decimal ratePerMonth = getShopRatePerMonth(); decimal totalAmount = ratePerMonth * noOfMonths; CashDistributionEngine cashDistributionEnginge = get_CashDistributionEngineAndCheckBalance(totalAmount, true); string explaintion = string.Format("{0}. All your products will be collected and will be shown in your shop. Note, every shop must have a unique name and will be created in its own area. This shop will be created in: ", cashDistributionEnginge.Message); AddressStringWithNames customerAddress = getDefaultCustomerAddress(); ShopVM shopCreate = new ShopVM( product.Id, product.Name, explaintion, noOfMonths, ratePerMonth, returnUrl, shopNames, menuPathMain, customerAddress, product.MiscFiles_Fixed); shopCreate.Id = product.Id; return(shopCreate); }
public Shop() { InitializeComponent(); shopVM = ShopVM.Instance; customerVM = CustomerVM.Instance; //Makes sure the "ShopListBox" only populates once when navigating to the "Shop" page. if (shopVM.ListOfProducts.Count == 0) { shopVM.PopulateList(); } // Sets the itemsource again to make sure it is binded to the list "ListOfProducts" in "ShopVM" after it has been populated ShopListBox.ItemsSource = shopVM.ListOfProducts; }
private void UpdateExpiryDate(Product product, ShopVM shopVm) { //if the date is null if (product.ShopExpiryDate.Date_NotNull_Min == DateTime.MinValue) { product.ShopExpiryDate.Date = DateTime.Now; } else { DateParameter dp = new DateParameter(); //if the date expired before today if (dp.Date1AfterDate2(DateTime.Now, product.ShopExpiryDate.Date_NotNull_Min)) { product.ShopExpiryDate.Date = DateTime.Now; } //else the date is today or after today. In either case add the month to that date. } int noOfMonths = shopVm.NoOfMonths; DateTime newDate = product.ShopExpiryDate.Date_NotNull_Min.AddMonths(noOfMonths); product.ShopExpiryDate.SetDateTo(UserName, UserId, newDate); }
public ActionResult Shop() { // shop is list of Lists of weights and mechines DataLayer dal = new DataLayer(); List <Product> objProduct = (from x in dal.Products select x).ToList <Product>(); ShopVM shop = new ShopVM(); shop.prods = objProduct; // list of products of type Weights from DB List <Weights> objWeights = (from x in dal.Weights select x).ToList <Weights>(); ShopVM Weights = new ShopVM(); shop.Weights = objWeights; // list of products of type Mechine from DB List <Mechine> objMechines = (from x in dal.Mechines select x).ToList <Mechine>(); ShopVM Mechines = new ShopVM(); shop.Mechines = objMechines; // return the view return(View(shop)); }
public ActionResult Search(ShopVM shop) { _ps.GetShopContent(shop); FixPrices(shop); return(View("Index", shop)); }
//Shop public void AddShop(ShopVM shop) { _shopLogic.AddShop(shop.NameShop, shop.IdTypeOfShop, shop.IdAddress, out var alert); }
public async Task <ShopCreatedSuccessfullyVM> Setup_To_Edit_Shop_Post_Async(ShopVM shopVm, string button, HttpPostedFileBase[] httpMiscUploadedFiles) { UserId.IsNullOrWhiteSpaceThrowException("You are not logged in."); shopVm.IsNullThrowExceptionArgument("Shop"); button.IsNullOrWhiteSpaceThrowArgumentException("button"); Owner userOwner = OwnerBiz.GetPlayerFor(UserId); userOwner.IsNullThrowException("You are not authourized to create a shop. Please become a seller first."); if (button == "accept") { //locate the shop if (shopVm.NoOfMonths == 0) { throw new Exception("No of months is zero"); } decimal salePrice = MenuPathMain.Payment_To_Buy_Shop(); int quantity = shopVm.NoOfMonths; //see if User has the money to do what they want. decimal paymentAmount = salePrice * quantity; bool isNonRefundablePaymentAllowed = true; CashDistributionEngine cde = get_CashDistributionEngineAndCheckBalance(paymentAmount, isNonRefundablePaymentAllowed); //get the shop Child Product ProductChild shopBuySellItem = ProductChildBiz.FindForName(ProductChild.GetShopName()); shopBuySellItem.IsNullThrowException("Shop not found"); Owner ownerOfProductChild = shopBuySellItem.Owner; ownerOfProductChild.IsNullThrowException("No Product Child Owner"); Customer customerUser = getCustomerOfUser(); Product product = ProductBiz.Find(shopVm.Id); product.IsNullThrowException("product"); string shopId = product.Id; updateTheProductFromTheShopVm(product, shopVm); SelectList selectListOwner = null; SelectList selectListCustomer = null; SelectList selectListBillTo = null; SelectList selectListShipTo = null; string addressBillToId = ""; string addressShipToId = ""; DateTime expectedDeliveryDate = DateTime.Now; DateTime guaranteePeriodEnds = DateTime.Now; BuySellDoc sale = CreateSale( shopBuySellItem, ownerOfProductChild, quantity, salePrice, customerUser, selectListOwner, selectListCustomer, addressBillToId, addressShipToId, selectListBillTo, selectListShipTo, BuySellDocStateENUM.RequestUnconfirmed, BuySellDocStateModifierENUM.Accept, expectedDeliveryDate, guaranteePeriodEnds, shopId); product.BuySellDocs.Add(sale); ControllerCreateEditParameter parm = new ControllerCreateEditParameter( product as ICommonWithId, httpMiscUploadedFiles, null, null, null, null, null, null, null, MenuENUM.EditDefault, UserName, UserId, shopVm.ReturnUrl, null, //globalObject not required for products button); await ProductBiz.UpdateAndSaveAsync(parm); MenuPathMain mpm = product.MenuPathMains_Fixed.FirstOrDefault(); decimal refundable_Spent = cde.Refundable_Final; decimal nonRefundable_spent = cde.NonRefundable_Final; string shopName = product.FullName(); string mp1Name = mpm.MenuPath1.FullName(); string mp2Name = mpm.MenuPath2.FullName(); string mp3Name = mpm.MenuPath3.FullName(); int numberOfMonths = quantity; DateTime expiryDate = product.ShopExpiryDate.Date_NotNull_Min; ShopCreatedSuccessfullyVM shopCreatedSuccessfully = new ShopCreatedSuccessfullyVM( refundable_Spent, nonRefundable_spent, shopName, mp1Name, mp2Name, mp3Name, numberOfMonths, expiryDate, shopVm.ReturnUrl); return(shopCreatedSuccessfully); } return(null); }
public ProductProfile() { InitializeComponent(); shopVM = ShopVM.Instance; this.DataContext = shopVM; }
private void updateTheProductFromTheShopVm(Product product, ShopVM shopVm) { //update the name product.Name = shopVm.ShopName; UpdateExpiryDate(product, shopVm); }
public async Task <ShopCreatedSuccessfullyVM> Setup_To_Create_Shop_Post_Async(ShopVM shopCreate, string button, HttpPostedFileBase[] httpMiscUploadedFiles) { UserId.IsNullOrWhiteSpaceThrowException("You are not logged in."); shopCreate.MenuPathMainId.IsNullOrWhiteSpaceThrowException("Main Menu Path not received"); Owner userOwner = OwnerBiz.GetPlayerFor(UserId); userOwner.IsNullThrowException("You are not authourized to create a shop. Please become a seller first."); if (button == "accept") { //CashDistributionEngine cde; //int quantity; //Product product; //MenuPathMain mpm; //ControllerCreateEditParameter parm = setup_Shop_Into_ControllerCreateEditParameter(shopCreate, button, httpMiscUploadedFiles, userOwner, out cde, out quantity, out product, out mpm, out parm); decimal paymentAmount = MenuPathMain.Payment_To_Buy_Shop(); decimal commissionPct = BuySellDoc.Get_Maximum_Commission_Product_Percent(); bool isNonRefundablePaymentAllowed = true; CashDistributionEngine cde = get_CashDistributionEngineAndCheckBalance(paymentAmount, isNonRefundablePaymentAllowed); //check the name, if it is already used, throw error and return to create screen if (isShopNameExists(shopCreate.ShopName)) { string err = string.Format("The shop name '{0}' already exists... sorry. Try again.", shopCreate.ShopName); throw new Exception(err); } //create the shop int quantity = shopCreate.NoOfMonths; if (quantity == 0) { throw new Exception("The quantity is zero. This is not allowed"); } Customer customerUser = getCustomerOfUser(); SelectList selectListOwner = null; SelectList selectListCustomer = null; SelectList selectListBillTo = null; SelectList selectListShipTo = null; string addressBillToId = ""; string addressShipToId = ""; decimal salePrice = MenuPathMain.Payment_To_Buy_Shop(); DateTime expectedDeliveryDate = DateTime.Now; DateTime guaranteePeriodEnds = DateTime.Now; //MenuPathMain mpm = MenuPathMainBiz.Find(shopCreate.MenuPathMainId); //mpm.IsNullThrowException("Menu Path Main is null"); MenuPathMain mpm = getMainMenuPath(shopCreate); Product product = setup_Product_For_Shop(shopCreate, userOwner); //get the shop Child Product ProductChild shopBuySellItem = ProductChildBiz.FindForName(ProductChild.GetShopName()); shopBuySellItem.IsNullThrowException("Shop not found"); string shopId = product.Id; Owner ownerOfProductChild = shopBuySellItem.Owner; ownerOfProductChild.IsNullThrowException("No Product Child Owner"); BuySellDoc sale = CreateSale( shopBuySellItem, ownerOfProductChild, quantity, salePrice, customerUser, selectListOwner, selectListCustomer, addressBillToId, addressShipToId, selectListBillTo, selectListShipTo, BuySellDocStateENUM.RequestUnconfirmed, BuySellDocStateModifierENUM.Accept, expectedDeliveryDate, guaranteePeriodEnds, shopId); product.BuySellDocs.Add(sale); ControllerCreateEditParameter parm = new ControllerCreateEditParameter( product as ICommonWithId, httpMiscUploadedFiles, null, null, null, null, null, null, null, MenuENUM.EditDefault, UserName, UserId, shopCreate.ReturnUrl, GetGlobalObject(), button); await ShopBiz.CreateAndSaveAsync(parm); decimal refundable_Spent = cde.Refundable_Final; decimal nonRefundable_spent = cde.NonRefundable_Final; string shopName = product.FullName(); string mp1Name = mpm.MenuPath1.FullName(); string mp2Name = mpm.MenuPath2.FullName(); string mp3Name = mpm.MenuPath3.FullName(); int numberOfMonths = quantity; DateTime expiryDate = product.ShopExpiryDate.Date_NotNull_Min; ShopCreatedSuccessfullyVM shopCreatedSuccessfully = new ShopCreatedSuccessfullyVM( refundable_Spent, nonRefundable_spent, shopName, mp1Name, mp2Name, mp3Name, numberOfMonths, expiryDate, shopCreate.ReturnUrl); //BuySellDocBiz.SaveChanges(); return(shopCreatedSuccessfully); } else { string err = string.Format("You caneled the operation."); throw new Exception(err); } }
private ControllerCreateEditParameter setup_Shop_Into_ControllerCreateEditParameter( ShopVM shopCreate, string button, HttpPostedFileBase[] httpMiscUploadedFiles, Owner userOwner, out CashDistributionEngine cde, out int quantity, out Product product, out MenuPathMain mpm, out ControllerCreateEditParameter parm) { decimal paymentAmount = MenuPathMain.Payment_To_Buy_Shop(); decimal commissionPct = BuySellDoc.Get_Maximum_Commission_Product_Percent(); bool isNonRefundablePaymentAllowed = true; cde = get_CashDistributionEngineAndCheckBalance(paymentAmount, isNonRefundablePaymentAllowed); //check the name, if it is already used, throw error and return to create screen if (isShopNameExists(shopCreate.ShopName)) { string err = string.Format("The shop name '{0}' already exists... sorry. Try again.", shopCreate.ShopName); throw new Exception(err); } //create the shop //get the shop Child Product ProductChild shop = ProductChildBiz.FindForName(ProductChild.GetShopName()); shop.IsNullThrowException("Shop not found"); Owner ownerProductChild = shop.Owner; ownerProductChild.IsNullThrowException("No Product Child Owner"); quantity = shopCreate.NoOfMonths; if (quantity == 0) { throw new Exception("The quantity is zero. This is not allowed"); } Customer customerUser = getCustomerOfUser(); SelectList selectListOwner = null; SelectList selectListCustomer = null; SelectList selectListBillTo = null; SelectList selectListShipTo = null; string addressBillToId = ""; string addressShipToId = ""; decimal salePrice = MenuPathMain.Payment_To_Buy_Shop(); DateTime expectedDeliveryDate = DateTime.Now; DateTime guaranteePeriodEnds = DateTime.Now; //MenuPathMain mpm = MenuPathMainBiz.Find(shopCreate.MenuPathMainId); //mpm.IsNullThrowException("Menu Path Main is null"); mpm = getMainMenuPath(shopCreate); product = setup_Product_For_Shop(shopCreate, userOwner); string shopId = product.Id; BuySellDoc sale = CreateSale( shop, ownerProductChild, quantity, salePrice, customerUser, selectListOwner, selectListCustomer, addressBillToId, addressShipToId, selectListBillTo, selectListShipTo, BuySellDocStateENUM.RequestUnconfirmed, BuySellDocStateModifierENUM.Accept, expectedDeliveryDate, guaranteePeriodEnds, shopId); product.BuySellDocs.Add(sale); parm = new ControllerCreateEditParameter( product as ICommonWithId, httpMiscUploadedFiles, null, null, null, null, null, null, null, MenuENUM.EditDefault, UserName, UserId, shopCreate.ReturnUrl, GetGlobalObject(), button); return(parm); }