Exemplo n.º 1
0
 private void OnAddUser(object sender, EventArgs e)
 {
     using (var form = new CreateUserForm())
     {
         form.ShowDialog();
     }
 }
Exemplo n.º 2
0
        public async Task <ActionResult> Create(CreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new Account.Models.ApplicationUser {
                    UserName = model.Email, Email = model.Email, LastName = model.LastName, FirstName = model.FirstName, Title = model.Title, TimeZone = model.TimeZone, LastLogin = DateTime.Parse("1/1/1")
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Details", "User", new { area = "User", id = user.Id }));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            //model.TimeZones = Account.Helpers.TimeZoneHelpers.GetTimeZones();
            Breadcrumbs breadcrumbs = new Breadcrumbs(Url);

            breadcrumbs.AddCrumb("Users", Url.Action("Index", "User"));
            breadcrumbs.AddCrumb("Create");
            ViewData["Breadcrumbs"] = breadcrumbs;
            ViewData["Form"]        = new CreateUserForm().Init(model);
            return(View(model));
        }
Exemplo n.º 3
0
        static void Main()
        {
            log4net.Config.XmlConfigurator.Configure();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!File.Exists("WriteLines.txt"))
            {
                PassSQL SqlForm = new PassSQL();
                SqlForm.ShowDialog();
                if (SqlForm.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }
            try
            {
                string[] lines = System.IO.File.ReadAllLines("WriteLines.txt");
                DatabaseFactory.CreateNewDatabase("", GetConnectionString(lines[0], lines[1]));
            }
            catch (Exception e)
            {
                File.Delete("WriteLines.txt");
                MessageBox.Show("Lỗi database! Xin chạy lại chương trình!");
                Log.Error(e.Message, e);
            }

            try
            {
                if (!Helper.checkAdminExists(DatabaseContants.tables.clinicuser))
                {
                    CreateUserForm createUserForm = new CreateUserForm();
                    if (createUserForm.ShowDialog() == DialogResult.OK)
                    {
                        LoginForm login = new LoginForm();

                        if (login.ShowDialog() == DialogResult.OK)
                        {
                            Application.Run(new Form1(LoginForm.Authority, LoginForm.Name1));
                        }
                    }
                }
                else
                {
                    LoginForm login = new LoginForm();

                    if (login.ShowDialog() == DialogResult.OK)
                    {
                        Application.Run(new Form1(LoginForm.Authority, LoginForm.Name1));
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
            }
        }
Exemplo n.º 4
0
        public IActionResult Create(CreateUserForm form)
        {
            var user = new User {
                Name = form.Name
            };

            _userRepository.Add(user);

            return(RedirectToAction("Details", new { id = user.Id }));
        }
        private static void SetRoles(CreateUserForm form, bool includeAll = false)
        {
            var items = new List <SelectListItem>();

            if (includeAll)
            {
                items.Add(new SelectListItem
                {
                    Value    = null,
                    Text     = "Все роли",
                    Group    = default,
Exemplo n.º 6
0
        public ActionResult Create()
        {
            CreateViewModel model = new CreateViewModel();
            //model.TimeZones = Account.Helpers.TimeZoneHelpers.GetTimeZones();
            Breadcrumbs breadcrumbs = new Breadcrumbs(Url);

            breadcrumbs.AddCrumb("Users", Url.Action("Index", "User"));
            breadcrumbs.AddCrumb("Create");
            ViewData["Breadcrumbs"] = breadcrumbs;
            ViewData["Form"]        = new CreateUserForm().Init(model);
            return(View(model));
        }
Exemplo n.º 7
0
        public Users Map(CreateUserForm form)
        {
            var user = new Users();

            user.HospitalLocation = form.HospitalLocation;
            user.HospitalName     = form.HospitalName;
            user.IsAdmin          = form.IsAdmin;
            user.Role             = form.Role;
            user.Password         = form.Password;
            user.UserName         = form.UserName;
            user.Lastlogin        = DateTime.Now;
            return(user);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> CreateUser([FromBody] CreateUserForm userForm)
        {
            if (!ModelState.IsValid)
            {
                BadRequest(ModelState);
            }
            var user = new UserModel()
            {
                username = userForm.Username,
                password = Cipher.HashPassword(userForm.Password),
                Role     = userForm.Role
            };

            _context.UserModels.Add(user);
            _context.SaveChanges();
            return(Ok(user.Guid.ToString()));
        }
Exemplo n.º 9
0
        private void CreateFirstUser(EventArgs args)
        {
            NoUsersDetected?.Invoke(this, args);
            var res = MessageBox.Show("There are no users now, do you want to create new one?",
                                      "No users yet", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (res == DialogResult.Yes)
            {
                using (var form = new CreateUserForm())
                {
                    form.ShowDialog();
                }
            }
            else
            {
                ClosingFormInvoked?.Invoke(this, args);
            }
        }
        public IActionResult Create()
        {
            if (!RoleIs(Role.Administrator))
            {
                return(Forbid());
            }


            var form = new CreateUserForm
            {
                Entrances   = GetEntranceItems(_entranceService.AllActive()),
                Departments = GetDepartmentItems(_departmentService.AllActive())
            };

            SetRoles(form);

            return(View(form));
        }
        public async Task <IActionResult> Create([FromBody] CreateUserForm model)
        {
            var user = new ApplicationUser
            {
                givenname          = model.givenname,
                familyname         = model.familyname,
                AccessFailedCount  = 0,
                Email              = model.email,
                EmailConfirmed     = false,
                LockoutEnabled     = true,
                NormalizedEmail    = model.username.ToUpper(),
                NormalizedUserName = model.username.ToUpper(),
                TwoFactorEnabled   = false,
                UserName           = model.username
            };


            if (!model.password.Equals(model.passwordvalidate))
            {
                return(BadRequest("Passwords don't match"));
            }

            var result = await usermanager.CreateAsync(user, model.password);


            if (result.Succeeded)
            {
                var roleresult = await usermanager.AddToRoleAsync(user, model.rolename);

                if (roleresult.Succeeded)
                {
                    var claims = new List <Claim> {
                        new Claim(type: JwtClaimTypes.GivenName, value: user.givenname),
                        new Claim(type: JwtClaimTypes.FamilyName, value: user.familyname),
                    };
                    await usermanager.AddClaimsAsync(user, claims);

                    return(Ok());
                }
            }

            return(BadRequest("Passwords don't match"));
        }
        public IActionResult Create(CreateUserForm form)
        {
            if (!RoleIs(Role.Administrator))
            {
                return(Forbid());
            }


            return(Form(
                       form,
                       (int userId) => this.RedirectToAction(x => x.List()),
                       () =>
            {
                SetRoles(form);

                form.Entrances = GetEntranceItems(_entranceService.AllActive(), form.EntranceId);
                form.Departments = GetDepartmentItems(_departmentService.AllActive(), form.DepartmentId);

                return View(form);
            }));
        }
Exemplo n.º 13
0
        public virtual IActionResult CreateUser([FromBody] CreateUserForm creatRoleForm)
        {
            User userForCreate = mapper.Map <User>(creatRoleForm);

            userForCreate.UserName = userForCreate.Email;
            IdentityResult createRoleResult = userManager.CreateAsync(userForCreate, creatRoleForm.Password).Result;

            if (!createRoleResult.Succeeded)
            {
                foreach (var message in createRoleResult.Errors)
                {
                    ModelState.AddModelError(string.Empty, message.Description);
                }
                ResponseMessage responseMessage = new ResponseMessage();
                responseMessage.Title      = "مقادیر ارسالی صحیح نیستند";
                responseMessage.Descripton = ModelState.GetSingleLineErrorMessages();
                return(BadRequest(responseMessage));
            }

            UserDto createdRole = mapper.Map <UserDto>(userForCreate);

            return(Created(Url.Link(nameof(GetUser), new { id = createdRole.Id }), createdRole));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Create(CreateUserForm model)
        {
            if (ModelState.IsValid)
            {
                AppUser user = new AppUser
                {
                    UserName = model.Name,
                    Email    = model.Email
                };

                IdentityResult result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }

                foreach (IdentityError error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }
            return(View(model));
        }
Exemplo n.º 15
0
        public void RegisterUser([FromBody] CreateUserForm user)
        {
            var map = _addUserMapper.Map(user);

            _addUserRepository.InsertUser(map);
        }
        private void addUserButton_Click(object sender, EventArgs e)
        {
            CreateUserForm form = new CreateUserForm(_role, () => renderUsers());

            form.Show();
        }
Exemplo n.º 17
0
        public IActionResult Create()
        {
            var model = new CreateUserForm();

            return(View(model));
        }
Exemplo n.º 18
0
        public void EditUser([FromUri] int id, [FromBody] CreateUserForm user)
        {
            var map = _addUserMapper.Map(id, user);

            _addUserRepository.UpdateUser(map);
        }
Exemplo n.º 19
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            CreateUserForm Create = new CreateUserForm(this);

            Create.Show();
        }