public ActionResult AddDiscountCoupon() { BusinessDomainLogic businessDomainLogic = new BusinessDomainLogic(); ShoppingCartDomainLogic shoppingCartDomainLogic = new ShoppingCartDomainLogic(); var model = new Discount(); model.BranchList = businessDomainLogic.GetBranchList(UserVariables.LoggedInUserGuid); var branch = model.BranchList.Count > 0 ? model.BranchList[0] : null; if (branch != null) { Guid branchGuid = Guid.Empty; Guid.TryParse(branch.Value, out branchGuid); model.ProductList = GetProductListByBranchGuid(branchGuid); model.ProductList = model.ProductList ?? new List <CustomSelectListItem>(); } return(View("AddDiscountCoupon", model)); }
public ActionResult UpdateDiscountCoupon(Discount discount) { if (!ModelState.IsValid) { return(View("EditCoupon", discount)); } if (discount.DiscountType == 2 && (discount.ProductIds == null || discount.ProductIds.Length < 1)) { ModelState.AddModelError("ProductIds", "Select at least one product."); BusinessDomainLogic businessDomainLogic = new BusinessDomainLogic(); discount.BranchList = businessDomainLogic.GetBranchList(UserVariables.LoggedInUserGuid); if (discount.BranchGuid != null && discount.BranchGuid != Guid.Empty) { discount.ProductList = GetProductListByBranchGuid(discount.BranchGuid); discount.ProductList = discount.ProductList ?? new List <CustomSelectListItem>(); } return(View("EditCoupon", discount)); } if (discount.DiscountPriceType == 1 && discount.DiscountValue > 100) { ModelState.AddModelError("DiscountValue", "Percentage Value cann't be greater than 100%."); BusinessDomainLogic businessDomainLogic = new BusinessDomainLogic(); discount.BranchList = businessDomainLogic.GetBranchList(UserVariables.LoggedInUserGuid); if (discount.BranchGuid != null && discount.BranchGuid != Guid.Empty) { discount.ProductList = GetProductListByBranchGuid(discount.BranchGuid); discount.ProductList = discount.ProductList ?? new List <CustomSelectListItem>(); } return(View("EditCoupon", discount)); } ShoppingCartDomainLogic shoppingCartDomainLogic = new ShoppingCartDomainLogic(); var result = shoppingCartDomainLogic.UpdateDicountCoupon(discount); var message = result ? "Coupon has been updated." : "Operation failled."; TempData["hasError"] = !result; TempData["message"] = message; return(RedirectToAction("coupons")); }
public ActionResult EditCoupon(int couponId) { ShoppingCartDomainLogic shoppingCartDomainLogic = new ShoppingCartDomainLogic(); BusinessDomainLogic businessDomainLogic = new BusinessDomainLogic(); var model = shoppingCartDomainLogic.GetDiscountCoupon(couponId); model.BranchList = businessDomainLogic.GetBranchList(UserVariables.LoggedInUserGuid); if (model.BranchGuid != null && model.BranchList.Count > 0) { var selectedBranch = model.BranchList.Where(x => x.Value == model.BranchGuid.ToString()).Select(b => b).FirstOrDefault(); if (selectedBranch != null) { Guid branchGuid = Guid.Empty; Guid.TryParse(selectedBranch.Value, out branchGuid); model.ProductList = GetProductListByBranchGuid(branchGuid); model.ProductList = model.ProductList ?? new List <CustomSelectListItem>(); } } return(View("EditCoupon", model)); }