Beispiel #1
0
        public ActionResult Edit(int id)
        {
            var service = CreateAdminService();
            var detail  = service.GetAdminByID(id);
            var model   =
                new AdminUpdate
            {
                AdminID   = detail.AdminID,
                AdminName = detail.AdminName
            };

            return(View(model));
        }
Beispiel #2
0
        public bool UpdateAdmin(AdminUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Admins
                    .Single(e => e.AdminID == model.AdminID && e.OwnerID == _userID);
                entity.AdminName = model.AdminName;

                return(ctx.SaveChanges() == 1);
            }
        }
        public bool UpdateAdmin(AdminUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .BBShopAdmins
                    .Single(e => e.AdminID == model.AdminID);
                entity.CustomerID = model.CustomerID;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id)
        {
            var detail = _service.GetAdminByID(id);
            var model  =
                new AdminUpdate
            {
                AdminID    = detail.AdminID,
                CustomerID = detail.CustomerID
            };
            CustomerService custSvc = new CustomerService(Guid.Parse(User.Identity.GetUserId()));

            ViewBag.CustomerID = new SelectList(custSvc.GetCustomer(), "CustomerID", "FullName");
            return(View(model));
        }
Beispiel #5
0
 public bool UpdateAdmin(AdminUpdate model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Users
             .Single(e => e.Id == model.CustomerID);
         //entity.Id = model.CustomerID;
         //var roleEntity =
         //    ctx
         //    .
         return(ctx.SaveChanges() == 1);
     }
 }
Beispiel #6
0
        public ActionResult Edit(string id)
        {
            var detail = _service.GetAdminByID(id);
            var model  =
                new AdminUpdate
            {
                CustomerID = detail.UserID,
                RoleID     = detail.RoleID
            };
            CustomerService custSvc  = new CustomerService(Guid.Parse(User.Identity.GetUserId()));
            AdminService    identSvc = new AdminService();

            ViewBag.CustomerID = new SelectList(custSvc.GetCustomer(), "CustomerID", "FullName");
            ViewBag.Id         = new SelectList(identSvc.GetRole(), "Id", "Name");
            return(View(model));
        }
Beispiel #7
0
        public ActionResult Edit(AdminUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //if (model.AdminID != id)
            //{
            //    ModelState.AddModelError("", "Id Mismatch");
            //    return View(model);
            //}
            if (_service.UpdateAdmin(model))
            {
                TempData["SaveResult"] = "Your customer was updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your customer could not be updated.");
            return(View(model));
        }
Beispiel #8
0
        public ActionResult Edit(int id, AdminUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.AdminID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = CreateAdminService();

            if (service.UpdateAdmin(model))
            {
                TempData["SaveResult"] = "Your customer was updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your customer could not be updated.");
            return(View(model));
        }
Beispiel #9
0
        public async Task <IActionResult> UpdateAdmin(int id, [FromBody] AdminUpdate adminUpdate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var admin = await _adminRepo.GetAdmin(id);

            if (admin == null)
            {
                return(NotFound($"Пользователя с Id {id} не существует"));
            }


            _adminMapper.Map(adminUpdate, admin);

            if (await _adminRepo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Пользователь {id} НЕ обновлен!");
        }