Ejemplo n.º 1
0
        // GET: Admin/User/Create
        public ActionResult Create()
        {
            AddEditUserViewModel model = new AddEditUserViewModel();
            model.ClientsList = _adminRepo.GetAllClients();

            return View(model);
        }
Ejemplo n.º 2
0
        // GET: Admin/User/Edit/5
        public ActionResult Edit(long id)
        {
            User user = _adminRepo.GetUserById(id);
            IEnumerable<Client> clients = _adminRepo.GetAllClients();

            AddEditUserViewModel model = new AddEditUserViewModel()
            {
                Id = user.Id,
                ClientId = user.ClientId,
                Username = user.Username,
                ClientsList = clients
            };

            return View(model);
        }
Ejemplo n.º 3
0
        public ActionResult Create(AddEditUserViewModel input)
        {
            try
            {
                User user = new User
                {
                    Username = input.Username,
                    ClientId = input.ClientId,
                    Password = input.Password
                };

                _adminRepo.SaveUser(user);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }