public ActionResult Add(UserProductViewModel model, string[] roleIds) { if (UserDAL.Add(model.User, roleIds)) { return(JsonSuccess("")); } ViewData[Info] = SaveError; return(JsonError("")); }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult Add() { ViewData[EditFlag] = true; UserProductViewModel userpor = new UserProductViewModel(); userpor.ProductList = ProductModel.Fetch(""); userpor.RoleList = RoleModel.Fetch(""); return(View(userpor)); }
// GET: Prodcut form to create a product public ActionResult Create() { var categories = categoryService.GetAll(); var viewModel = new UserProductViewModel { Categories = categories }; return(View(viewModel)); }
public ActionResult Edit(Product product) { if (ModelState.IsValid) { productService.Update(product); return(RedirectToAction("Index")); } var viewModel = new UserProductViewModel { Product = product, Categories = categoryService.GetAll() }; return(View(viewModel)); }
// GET: Products/MyProducts //This method is used to display products only for the current logged in user public async Task <IActionResult> MyProducts() { // Create new instance of the view model UserProductViewModel model = new UserProductViewModel(); //grab the current user var user = await _userManager.GetUserAsync(HttpContext.User); //grab products equal to current user ID model.Products = await(_context.Product.Where(p => p.User == user).ToListAsync()); return(View(model)); }
public ActionResult Edit(int?id, int actiontype = 0) { UserProductViewModel userpor = new UserProductViewModel(); ViewBag.actiontype = actiontype; if (actiontype == 1) { ViewData[EditFlag] = true; userpor.ProductList = ProductModel.Fetch(""); userpor.RoleList = RoleModel.Fetch(""); return(View(userpor)); } userpor.ProductList = ProductModel.Fetch(""); userpor.UserProductList = UserProductModel.Fetch(" where userid = " + id); userpor.RoleList = RoleModel.Fetch(""); userpor.UserRoleList = UserRoleModel.Fetch(" where userid = " + id); userpor.User = UserModel.FirstOrDefault(" where id = " + id); ViewData[EditFlag] = true; return(View(userpor)); }
// GET: Products/Edit/id public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var product = productService.Get(id); if (product == null) { return(HttpNotFound()); } var viewModel = new UserProductViewModel { Product = product, Categories = categoryService.GetAll() }; return(View(viewModel)); }
public ActionResult Edit(UserProductViewModel model, string[] roleIds) { if (string.IsNullOrEmpty(model.User.ID)) { if (UserDAL.Add(model.User, roleIds)) { return(JsonSuccess("")); } ViewData[Info] = SaveError; return(JsonError("")); } else { if (UserDAL.Edit(model.User, roleIds)) { return(JsonSuccess("")); } } ViewData[Info] = SaveError; return(JsonError("")); }