public void AddSupplier(AddSupplierBm bind, int userId) { Supplier supplier = Mapper.Instance.Map <AddSupplierBm, Supplier>(bind); this.Context.Suppliers.Add(supplier); this.Context.SaveChanges(); this.AddLog(userId, OperationLog.Add, "suppliers"); }
public void AddSupplierFromBm(AddSupplierBm model, int userId) { var supplier = Mapper.Map <AddSupplierBm, Supplier>(model); this.context.Suppliers.Add(supplier); this.context.SaveChanges(); this.AddLog(OperationLog.Add, userId); }
public ActionResult Add([Bind(Include = "Name, IsImporter")] AddSupplierBm bind) { var httpCookie = this.Request.Cookies.Get("sessionId"); if (httpCookie == null || !AuthenticationManager.IsAuthenticated(httpCookie.Value)) { return(this.RedirectToAction("All")); } User loggedInUser = AuthenticationManager.GetAuthenticatedUser(httpCookie.Value); this.business.AddSupplier(bind, loggedInUser.Id); return(this.RedirectToAction("All")); }
public void AddSupplier(AddSupplierBm addSupplierBm, int userId) { Supplier supplier = Mapper.Map <AddSupplierBm, Supplier>(addSupplierBm); if (addSupplierBm.IsImporter == "on") { supplier.IsImporter = true; } else { supplier.IsImporter = false; } this.Context.Suppliers.Add(supplier); Context.SaveChanges(); this.AddLog(userId, OperationLog.Add, "suppliers"); }
public ActionResult AddSupplier([Bind(Include = "Name, IsImporter")] AddSupplierBm addSupplierBm) { HttpCookie cookie = this.Request.Cookies.Get("sessionId"); if (cookie == null || !AuthenticationManager.IsAuthenticated(cookie.Value)) { return(this.RedirectToAction("Login", "Users")); } if (!this.ModelState.IsValid) { return(this.View()); } User user = AuthenticationManager.GetAuthenticatedUser(cookie.Value); this.service.AddSupplier(addSupplierBm, user.Id); return(this.RedirectToAction("ViewSuppliers", "Supplier")); }
public ActionResult Add([Bind(Include = "Name, IsImporter")] AddSupplierBm model) { var httpCookie = this.Request.Cookies.Get("sessionId"); if (httpCookie == null || !AuthenticationManager.IsAuthenticated(httpCookie.Value)) { return(this.RedirectToAction("Login", "Users")); } var user = AuthenticationManager.GetUser(httpCookie.Value); ViewBag.Username = user.Username; if (this.ModelState.IsValid) { this.service.AddSupplierFromBm(model, user.Id); return(this.RedirectToAction("All", "Suppliers")); } return(this.View()); }