public IActionResult DeleteComment(int id, string product) { var result = BLL.DeleteComment.Do(id); TempData.AddOrUpdate("DeleteStatus", result); return(RedirectToAction("Index", "Product", new{ id = product })); }
public async Task <IActionResult> NewCategory(Category model, IFormFile picture) { string photoPath; try { if (picture != null) { photoPath = await _environment.AddFile(picture, "/img/"); model.PhotoPath = photoPath; } } catch (Exception e) { TempData.AddOrUpdate("CategoryError", e.Message); return(View("NewCategory")); } var message = CategoriesLogic.AddCategory(model); if (message.GetErrorMessage != null) { TempData.AddOrUpdate("CategoryError", message.GetErrorMessage); } return(View("NewCategory", message.GetModel)); }
public IActionResult Index(ProfileViewModel model, int page = 1, bool changeFilters = true) { if (changeFilters) { HttpContext.Session.SetOrUpdate <ProfileViewModel>("ProfileFilters", model); } else { model = HttpContext.Session.Get <ProfileViewModel>("ProfileFilters"); } if (User.IsInRole("User")) { model.UserName = User.Identity.Name; } if (model.Status == "-") { model.Status = null; } if (model.SortType == "-") { model.SortType = null; } model.Page = page; model.Qty = Qty; var result = ProfileLogic.GetProfile(model); if (result.GetModel != null) { return(View(result.GetModel)); } TempData.AddOrUpdate("Error", result.GetErrorMessage); return(Redirect(Request.Headers["Referer"].ToString())); }
public JsonResult GetCharacteristics(string categoryName) { var result = BLL.CategoriesLogic.GetCharacteristics(categoryName); if (result.GetErrorMessage != null) { TempData.AddOrUpdate("CharacteristicError", result.GetErrorMessage); } return(new JsonResult(result.GetModel)); }
public IActionResult Index(string id) { var model = BLL.ProductLogic.GetProductView(id); if (model.GetModel != null) { return(View(model.GetModel)); } TempData.AddOrUpdate("Error", model.GetErrorMessage); return(Redirect(Request.Headers["Referer"].ToString())); }
public IActionResult Search(string inputSearch) { List <Category> _categorys = BLL.CategoriesLogic.GetSearchOfCategory(inputSearch); if (_categorys.Count == 0) { TempData.AddOrUpdate("SearchError", "Not Found"); return(View("Categories", _categorys)); } return(View("Categories", _categorys)); }
public IActionResult Comment(ReviewViewModel model, string productId) { model.Product = productId; model.UserName = User.Identity.Name; var comment = ProductLogic.AddComment(model); if (comment.GetErrorMessage != null) { TempData.AddOrUpdate("CommentError", comment.GetErrorMessage); } return(Index(productId)); }
public IActionResult EditInfo(EditInfoViewModel model) { if (ModelState.IsValid) { model.UserName = User.Identity.Name; var result = ProfileLogic.EditMail(model); TempData.AddOrUpdate("EditMailMessage", result); return(RedirectToAction("Edit", "Account")); } TempData.Add("EditMailMessage", "Email is not valid"); return(RedirectToAction("Edit", "Account")); }
public async Task <IActionResult> LogIn(LogInViewModel model) { var user = LogInLogic.GetUser(model); if (user == null) { TempData.AddOrUpdate("LogInError", "Username or password is not correct!"); } else { await Authenticate(user); } return(Redirect(Request.Headers["Referer"].ToString())); }
public IActionResult Card() { var ids = HttpContext.Session.Get <Dictionary <string, int> >("Card"); var products = BLL.Card.GetCard(ids); if (products.GetModel != null) { return(View(products.GetModel)); } else { TempData.AddOrUpdate("EmptyCardError", products.GetErrorMessage); return(View()); } }
public IActionResult EditPassword(EditPasswordViewModel model) { if (ModelState.IsValid) { model.UserName = User.Identity.Name; var result = ProfileLogic.EditPassword(model); TempData.AddOrUpdate("EditPasswordMessage", result); return(RedirectToAction("Edit", "Account")); } if (ModelState["ConfirmPassword"].ValidationState == ModelValidationState.Invalid) { ModelState.AddModelError(string.Empty, "Passwords don't match"); } return(RedirectToAction("Edit", "Account")); }
public async Task <IActionResult> SignUp(SignUpViewModel model) { var user = RegisterLogic.Register(model); if (user.GetUser == null) { TempData.AddOrUpdate("SignUpError", user.GetErrorMessage); } else { await Authenticate(user.GetUser); } return(Redirect(Request.Headers["Referer"].ToString())); }
public IActionResult CategoryProducts(string category) { ClearHttp(); var filters = new ProductFiltersViewModel(); filters.Category = category; string inputString = Request.Query.FirstOrDefault(p => p.Key == "inputSearch").Value; filters.inputSearch = inputString; var model = CategoryProductLogic.GetProductsWithFilters(filters, 0, Qty, inputString); if (model.GetModel != null) { return(View(model.GetModel)); } TempData.AddOrUpdate("Error", model.GetErrorMessage); return(Redirect(Request.Headers["Referer"].ToString())); }
public async Task <IActionResult> NewProduct(Product product, IFormFile photo) { string photoPath; try { if (photo != null) { photoPath = await _environment.AddFile(photo, "/img/"); product.PhotoPath = photoPath; } } catch { ModelState.AddModelError("PhotoPath", "Can't handle photo=("); } TempData.AddOrUpdate("Success", BLL.ProductLogic.InsertProduct(product)); SetCategoriesInViewData(); return(View(product)); }