Ejemplo n.º 1
0
        public ActionResult Create()
        {
            var viewModel = new CreateUserViewModel();
            viewModel = CreateViewModel(viewModel);

            return View(viewModel);
        }
Ejemplo n.º 2
0
        public CreateUserViewModel CreateViewModel(CreateUserViewModel viewModel)
        {
            viewModel.RoleGroupList = _roleGroupService.GetRoleGroups(
                new Services.Requests.RoleGroup.GetRoleGroupsRequest { Skip = 0, Take = 0 }).RoleGroups.Select(x => new SelectListItem
                {
                    Text = x.Name,
                    Value = x.Id.ToString()
                }).ToList();

            return viewModel;
        }
Ejemplo n.º 3
0
        public ActionResult Create(CreateUserViewModel viewModel)
        {
            var request = viewModel.MapTo<CreateUserRequest>();
            var response = _userService.Create(request);
            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"] = response.Message;
            if (response.IsSuccess)
            {
                return RedirectToAction("Index");
            }

            return View("Create", viewModel);
        }
Ejemplo n.º 4
0
        public CreateUserViewModel CreateViewModel(CreateUserViewModel viewModel)
        {
            viewModel.RoleGroupList = _roleGroupService.GetRoleGroups(new Services.Requests.RoleGroup.GetRoleGroupsRequest
            {
                Take = -1,
                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
            })
                .RoleGroups.Select(x => new SelectListItem
                {
                    Text = x.Name,
                    Value = x.Id.ToString(),
                    Selected = viewModel.RoleId == x.Id ? true : false
                }).ToList();
            viewModel.IsActive = true;

            return viewModel;
        }
Ejemplo n.º 5
0
        public ActionResult Create(CreateUserViewModel viewModel)
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    if (!Directory.Exists(Path.Combine(Server.MapPath("~/Content/signature/"))))
                    {
                        Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Content/signature/")));
                    }
                    var path = Path.Combine(Server.MapPath("~/Content/signature/"), fileName);
                    var url = "/Content/signature/" + fileName;

                    file.SaveAs(path);
                    viewModel.SignatureImage = url;
                }
            }
            var request = viewModel.MapTo<CreateUserRequest>();
            var response = _userService.Create(request);
            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"] = response.Message;
            if (response.IsSuccess)
            {
                return RedirectToAction("Index");
            }

            return View("Create", viewModel);
        }