Пример #1
0
 public ActionResult EditAccount(ViewModels.AccountEditViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (var db = new Models.DBModel())
     {
         var account = db.AspNetUsers.FirstOrDefault(r => r.Id == model.Id);
         account.Id                   = model.Id;
         account.Email                = model.Email;
         account.EmailConfirmed       = model.EmailConfirmed;
         account.PasswordHash         = model.PasswordHash;
         account.SecurityStamp        = model.SecurityStamp;
         account.PhoneNumber          = model.PhoneNumber;
         account.PhoneNumberConfirmed = model.PhoneNumberConfirmed;
         account.TwoFactorEnabled     = model.TwoFactorEnabled;
         account.LockoutEndDateUtc    = model.LockoutEndDateUtc;
         account.LockoutEnabled       = model.LockoutEnabled;
         account.AccessFailedCount    = model.AccessFailedCount;
         account.UserName             = model.UserName;
         db.SaveChanges();
     }
     return(RedirectToAction("Admin"));
 }
Пример #2
0
 public ActionResult EditCategory(ViewModels.CategoryEditViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (var db = new Models.DBModel())
     {
         var category = db.ProductCategories.FirstOrDefault(r => r.id == model.id);
         category.name = model.name;
         category.id   = model.id;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Пример #3
0
 public ActionResult Edit(ViewModels.ProductEditViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (var db = new Models.DBModel())
     {
         var product = db.Products.FirstOrDefault(r => r.id == model.id);
         product.name        = model.name;
         product.description = model.description;
         product.price       = model.price;
         product.id          = model.id;
         product.categoryId  = model.categoryId;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Пример #4
0
 public ActionResult CreateCategory(ViewModels.CategoryCreateViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (var db = new Models.DBModel())
     {
         var category = new Models.ProductCategory
         {
             id   = model.id,
             name = model.name
         };
         db.ProductCategories.Add(category);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Пример #5
0
 public ActionResult CreateProduct(ViewModels.ProductCreateViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (var db = new Models.DBModel())
     {
         var product = new Models.Product
         {
             id          = model.id,
             name        = model.name,
             description = model.description,
             price       = model.price,
             categoryId  = model.categoryId
         };
         db.Products.Add(product);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }