public ActionResult CreateUser(CreateUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                Guid userId;

                using (var transaction = contextManager.NewTransaction())
                {
                    var userModel = mapperResolverService.Resolver <CreateUserViewModel, Models.User.User>(model);

                    userId = userService.UpsertUser(userModel);

                    transaction.Commit();
                }

                TempData["isRedirect"] = true;
                MessageCookie("Успешен запис!", "success");

                return(RedirectToAction("Index", "User"));
            }

            PrepareViewBag();

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Upsert(Guid?id)
        {
            RoleViewModel roleModel;

            if (id.HasValue)
            {
                using (var transaction = contextManager.NewTransaction())
                {
                    var role = roleService.GetRole(id.Value);
                    roleModel = mapperResolverService.Resolver <Role, RoleViewModel>(role);
                }
            }
            else
            {
                roleModel = new RoleViewModel();
            }

            PrepareViewBag();

            return(View(roleModel));
        }