public DeleteSupplierViewModel GetDeleteSupplierViewModel(int id)
        {
            Supplier supplierEntity    = this.DbContext.Suppliers.Find(id);
            DeleteSupplierViewModel vm = Mapper.Map <DeleteSupplierViewModel>(supplierEntity);

            return(vm);
        }
        public DeleteSupplierViewModel GetSupplierToDelete(int id)
        {
            Supplier supplier = this.Context.Suppliers.Find(id);
            DeleteSupplierViewModel mappedSuplier = Mapper.Map <Supplier, DeleteSupplierViewModel>(supplier);

            return(mappedSuplier);
        }
        public ActionResult DeleteSupplier(int id)
        {
            HttpCookie cookie = this.Request.Cookies.Get("sessionId");

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

            return(this.View(supplierBind));
        }
        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"));
        }
        public ActionResult Delete(int id)
        {
            DeleteSupplierViewModel vm = this.service.GetDeleteSupplierViewModel(id);

            return(this.View(vm));
        }