コード例 #1
0
        public void DeleteSupplier(DeleteSupplierBm bind, int userId)
        {
            Supplier supplier = this.Context.Suppliers.Find(bind.Id);

            this.Context.Suppliers.Remove(supplier);
            this.Context.SaveChanges();
            this.AddLog(userId, OperationLog.Edit, "suppliers");
        }
コード例 #2
0
        public ActionResult DeleteSupplier([Bind(Include = "Id")] DeleteSupplierBm deleteSupplierBm)
        {
            HttpCookie cookie = this.Request.Cookies.Get("sessionId");

            if (cookie == null || !AuthenticationManager.IsAuthenticated(cookie.Value))
            {
                return(this.RedirectToAction("Login", "Users"));
            }

            if (!this.ModelState.IsValid)
            {
                DeleteSupplierViewModel supplierBind = this.service.GetSupplierToDelete(deleteSupplierBm.Id);
                return(this.View(supplierBind));
            }
            User user = AuthenticationManager.GetAuthenticatedUser(cookie.Value);

            service.DeleteSupplier(deleteSupplierBm, user.Id);
            return(this.RedirectToAction("viewSuppliers", "Supplier"));
        }
コード例 #3
0
        public ActionResult Delete([Bind(Include = "Id")] DeleteSupplierBm bind)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticationManager.IsAuthenticated(httpCookie.Value))
            {
                return(RedirectToAction("All"));
            }

            if (!ModelState.IsValid)
            {
                DeleteSupplierVm vm = this.service.GetDeleteSupplier(bind.Id);
                return(this.View(vm));
            }
            User user = AuthenticationManager.GetAuthenticatedUser(httpCookie.Value);

            this.service.DeleteSupplier(bind, user.Id);
            return(this.RedirectToAction("All"));
        }