Example #1
0
        public IHttpActionResult PutDocument(int id, Document document)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != document.Id)
            {
                return(BadRequest());
            }

            db.Entry(document).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DocumentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "Id,Title,RequestDate,Flag,CreatedAt,UpdatedAt")] Request request)
 {
     if (ModelState.IsValid)
     {
         db.Entry(request).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(request));
 }
        public async Task <ActionResult> Edit([Bind(Include = "VatCategoryID,VatName,VatPercentage")] VatCategory vatCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(vatCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(vatCategory));
        }
 public ActionResult Edit([Bind(Include = "Id,Type,Description,State,UpdatedAt,CreatedAt")] Document document)
 {
     document.UpdatedAt = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(document).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(document));
 }
Example #5
0
        public async Task <ActionResult> Edit([Bind(Include = "ProductUnitOfMeasurementID,UnitName,UnitAbbreviation")] ProductUnitOfMeasurement productUnitOfMeasurement)
        {
            if (ModelState.IsValid)
            {
                db.Entry(productUnitOfMeasurement).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(productUnitOfMeasurement));
        }
        public async Task <ActionResult> Edit([Bind(Include = "InvoiceID,OrderID,InvoiceStatus,PaymentDueDate,DateCreated,TotalPrice")] Invoice invoice)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (User.IsInRole("Validated User") || User.IsInRole("Unvalidated User"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED" }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(invoice).State = EntityState.Modified;
                await db.SaveChangesAsync();

                InvoicesHub.BroadcastData();
                return(RedirectToAction("Index"));
            }
            ViewBag.OrderID = new SelectList(db.Orders, "OrderID", "UserId", invoice.OrderID);
            return(View(invoice));
        }
        public ActionResult AdminSave(AdminVM userInfo)
        {
            if (!ModelState.IsValid)
            {
                return(View("AdminEdit", userInfo));
            }

            else
            {
                var userInDb = _context.Users.Find(userInfo.UserId);
                _ = _context.Roles;
                var roleStore   = new RoleStore <IdentityRole>(new AppUsersDbContext());
                var roleManager = new RoleManager <IdentityRole>(roleStore);;

                userInDb.Id             = userInfo.UserId;
                userInDb.FirstName      = userInfo.FirstName;
                userInDb.LastName       = userInfo.LastName;
                userInDb.DateOfBirth    = userInfo.DateOfBirth;
                userInDb.Country        = userInfo.Country;
                userInDb.Region         = userInfo.Region;
                userInDb.City           = userInfo.City;
                userInDb.Street         = userInfo.Street;
                userInDb.StreetNumber   = userInfo.StreetNumber;
                userInDb.ZipCode        = userInfo.ZipCode;
                userInDb.Email          = userInfo.Email;
                userInDb.EmailConfirmed = userInfo.EmailConfirmed;
                userInDb.UserName       = userInfo.UserName;
                userInDb.Roles.Clear();

                var role = roleManager.FindById(userInfo.RoleId);
                roleManager.Create(new IdentityRole(role.Name));
                HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().AddToRole(userInDb.Id, role.Name);

                _context.Entry(userInDb).State = EntityState.Modified;
                _context.SaveChanges();
                return(RedirectToAction("AdminPage", "Users"));
            }
        }
Example #8
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,FirstName,MiddleName,LastName,DateofBirth,PersonalPhone,VendorID,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] ApplicationUser applicationUser)
        {
            if (!User.IsInRole("Administrator"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED - Adminstrator Only " }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(applicationUser).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.VendorID = new SelectList(db.Vendors, "VendorID", "VendorName", applicationUser.VendorID);
            return(View(applicationUser));
        }
        public async Task <ActionResult> Edit([Bind(Include = "ProductCategoryID,CategoryName,VatCategoryID")] ProductCategory productCategory)
        {
            if (User.IsInRole("Validated User") || User.IsInRole("Unvalidated User"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED" }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(productCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.VatCategoryID = new SelectList(db.VatCategories, "VatCategoryID", "VatName", productCategory.VatCategoryID);
            return(View(productCategory));
        }
Example #10
0
        public async Task <ActionResult> Edit([Bind(Include = "ProductInOrderID,ProductID,OrderID,Quantity")] ProductInOrder productInOrder)
        {
            if (!User.IsInRole("Administrator"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED - Restricted to administrator only!" }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(productInOrder).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.OrderID   = new SelectList(db.Orders, "OrderID", "UserId", productInOrder.OrderID);
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", productInOrder.ProductID);
            return(View(productInOrder));
        }
        public async Task <ActionResult> Edit([Bind(Include = "ProductID,ProductName,Description,ProductStatus,ProductCategoryID,ProductPrice,ProductUnitOfMeasurementID,UnitsInStock")] Product product)
        {
            if (User.IsInRole("Validated User") || User.IsInRole("Unvalidated User"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED" }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                product.ProductStatus   = (product.UnitsInStock > 0) ? (ProductStatus)0 : (ProductStatus)1;
                await db.SaveChangesAsync();

                ProductsHub.BroadcastData();
                return(RedirectToAction("Index"));
            }
            ViewBag.ProductCategoryID          = new SelectList(db.ProductCategories, "ProductCategoryID", "CategoryName", product.ProductCategoryID);
            ViewBag.ProductUnitOfMeasurementID = new SelectList(db.ProductUnitOfMeasurements, "ProductUnitOfMeasurementID", "UnitName", product.ProductUnitOfMeasurementID);
            return(View(product));
        }
        public async Task <ActionResult> Edit([Bind(Include = "VendorID,VendorName,VendorAFM,VendorLegalName,VendorDOI")] Vendor vendor)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (User.IsInRole("Validated User") || User.IsInRole("Unvalidated User"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED" }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(vendor).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(vendor));
        }
Example #13
0
        public async Task <ActionResult> Edit([Bind(Include = "OrderID,UserId,DateStarted")] Order order)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (!User.IsInRole("Administrator"))
            {
                return(RedirectToAction("Warning", "Home", new { message = "ACCESS DENIED" }));
            }
            if (ModelState.IsValid)
            {
                db.Entry(order).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", order.UserId);
            return(View(order));
        }