Пример #1
0
        public async Task <ActionResult> EditUser(EditUserModel model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#id"));
            }

            if (string.IsNullOrEmpty(model.FullName))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#fullName"));
            }

            if (string.IsNullOrEmpty(model.Password))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#password"));
            }

            if (!string.IsNullOrEmpty(model.Create))
            {
                if (await _backOfficeUsersRepository.UserExists(model.Id))
                {
                    return(this.JsonFailResult(Phrases.UserExists, "#id"));
                }
            }

            await _backOfficeUsersRepository.SaveAsync(model, model.Password);

            return(this.JsonRequestResult("#pamain", Url.Action("Index")));
        }
Пример #2
0
        private void CreateAdminUser(IApplicationBuilder app)
        {
            IBackOfficeUsersRepository usersRepository = app.ApplicationServices.GetService <IBackOfficeUsersRepository>();
            bool adminUser = usersRepository.UserExists("admin").Result;

            if (!adminUser)
            {
                usersRepository.CreateAsync(BackOfficeUser.CreateDefaultAdminUser("admin"), "123").Wait();
            }
        }