コード例 #1
0
        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");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
        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());
        }