public ActionResult Index(UserDTO userDto) { if (userDto.Id != null) { var user = _clientLogic.Get(userDto.Id); if (userDto.Discount >= 0 && userDto.Discount <= 100) { user.Discount = userDto.Discount; } _clientLogic.Edit(user); } return(RedirectToAction("Index")); }
public ActionResult Index(Cart cart, string returnUrl) { var cartIndexViewModel = new CartIndexViewModel { Cart = cart, ReturnUrl = returnUrl }; var client = _clientLogic.Get(User.Identity.GetUserId()); if (client != null) { ViewBag.userBlocked = client.IsBlocked; } return(View(cartIndexViewModel)); }
public ActionResult GoodsSearch(string search, FilterModelDTO filterDto, int page = 1) { var goods = _goodLogic.Search(search, filterDto); var goodViews = Mapper.Map <IEnumerable <GoodDTO>, IEnumerable <GoodViewModel> >(goods); var id = User.Identity.GetUserId(); var user = _clientLogic.Get(id); if (user != null) { foreach (var goodView in goodViews) { var dis = (100 - user.Discount) / 100; goodView.PriceWithDiscount = goodView.PriceSale * (decimal)dis; } } //todo: refactor -take goods grop _goodLogic int pageSize = 5; // количество объектов на страницу IEnumerable <GoodViewModel> goodssPerPages = goodViews.Skip((page - 1) * pageSize).Take(pageSize); PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = goodViews.Count() }; GoodListViewModel ivm = new GoodListViewModel { PageInfo = pageInfo, Goods = goodssPerPages }; if (ivm.Goods.Any()) { return(PartialView(goodViews.ToPagedList(page, pageSize))); } return(PartialView("SearchNull")); }