public ActionResult Add([Bind(Include = "Name,IsImporter")] AddSupplierBindingModel bind) { var httpCookie = this.Request.Cookies.Get("sessionId"); if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value)) { return(this.RedirectToAction("All")); } User loggedInUser = AuthenticatedManager.GetAuthenticatedUsers(httpCookie.Value); this.service.AddSupplier(bind, loggedInUser.Id); return(this.RedirectToAction("All")); }
public ActionResult All(string supplyerType) { var httpCookies = this.Request.Cookies.Get("sessionId"); if (httpCookies == null || !AuthenticatedManager.IsAuthenticated(httpCookies.Value)) { IEnumerable <SupplierViewModel> supplies = this.service.GetAllSuplyersByType(supplyerType); return(this.View(supplies)); } User user = AuthenticatedManager.GetAuthenticatedUsers(httpCookies.Value); ViewBag.Username = user.Username; IEnumerable <SuplierAllViewModel> vm = this.service.GetAllSupplierByTypeForUser(supplyerType); return(View("AllSuppliersForUser", vm)); }
public ActionResult Delete([Bind(Include = "Id")] DeleteSupplierBindingModel bind) { var httpCookie = this.Request.Cookies.Get("sessionId"); if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value)) { return(this.RedirectToAction("All")); } if (!this.ModelState.IsValid) { DeleteSuplierViewModel vm = this.service.GetDeleteSupplierVm(bind.Id); return(this.View(vm)); } User loggedInUser = AuthenticatedManager.GetAuthenticatedUsers(httpCookie.Value); this.service.DeleteSupplier(bind, loggedInUser.Id); return(this.RedirectToAction("All")); }