public ActionResult AddOffer(MarketViewModel marketList) { List<string> errors; if (Session["val"] != null) { errors = ((string[])Session["val"]).ToList(); } else { errors = new List<string>(); } if ((marketList.viewModel.Number == 0) || marketList.viewModel.Price == 0) { errors.Add("Coś poszło nie tak. Spróbuj ponownie."); Session["val"] = errors.ToArray<string>(); } else { MarketDto _marketDto = new MarketDto(); _marketDto.Login = User.Identity.Name; _marketDto.Product_Name = marketList.viewModel.Product_Name; _marketDto.Number = marketList.viewModel.Number; _marketDto.Price = marketList.viewModel.Price; _marketDto.TypeOffer = marketList.viewModel.TypeOffer; if (!_marketService.AddOffer(_marketDto)) { errors.Add("Coś poszło nie tak. Spróbuj ponownie."); Session["val"] = errors.ToArray<string>(); } } return RedirectToAction("Index"); }
public JsonResult BuyOffer(ItemMarketViewModel a) { MarketDto marketDto = new MarketDto(); marketDto.ID = a.ID; marketDto.Number = a.Number; marketDto.Price = a.Price; marketDto.Product_ID = a.Product_ID; marketDto.User_ID = a.User_ID; marketDto.TypeOffer = a.TypeOffer; if (_marketService.BuyOffer(marketDto, User.Identity.Name)) { return new JsonResult { Data = false }; } else { return new JsonResult { Data = false }; } }
public ActionResult AddOffer(UserProductViewModel marketModel) { List<string> errors; if (Session["val"] != null) { errors = ((string[])Session["val"]).ToList(); } else { errors = new List<string>(); } MarketDto _marketDto = new MarketDto(); _marketDto.Login = User.Identity.Name; _marketDto.Product_Name = marketModel.viewModel.Product_Name; _marketDto.Number = marketModel.viewModel.Value; _marketDto.Price = marketModel.viewModel.Price; _marketDto.TypeOffer = true; if(_marketService.AddOffer(_marketDto)) { errors.Add("Dodano ofertę."); } else { errors.Add("Błąd. Spróbuj ponownie."); } Session["val"] = errors.ToArray<string>(); return RedirectToAction("Index"); }
public ActionResult AddMarket(MarketViewModel marketModel) { List<string> errors; if (Session["val"] != null) { errors = ((string[])Session["val"]).ToList(); } else { errors = new List<string>(); } MarketDto _marketDto = new MarketDto(); _marketDto.Login = marketModel.viewModel.User_Login; _marketDto.Product_Name = marketModel.viewModel.Product_Name; _marketDto.Number = marketModel.viewModel.Number; _marketDto.Price = marketModel.viewModel.Price; _marketDto.TypeOffer = marketModel.viewModel.TypeOfferAdmin.ToLower().Contains("sprzedaż") ? true : false; if (_marketService.Add(_marketDto)) { errors.Add("Dodano ofertę."); } else { errors.Add("Błąd. Spróbuj ponownie."); } Session["val"] = errors.ToArray<string>(); return RedirectToAction("Admin"); }