コード例 #1
0
        public ActionResult CreateUserAndOAuth(FirstUserViewModel model)
        {
            if (Db.SingleOrDefault<User>(u => u.Email == model.Email) == null)
            {
                var user = new User
                    {
                        Name = "Администратор",
                        Email = model.Email,
                        UserRoles = Db.Select<Role>()
                    };
                Db.SaveOrUpdate(user);

                var setting = Db.SingleOrDefault<Setting>(s => s.Code == "YandexClientId");
                setting.Value = model.YandexClientId;
                Db.SaveOrUpdate(setting);

                setting = Db.SingleOrDefault<Setting>(s => s.Code == "YandexPassword");
                setting.Value = model.YandexPassword;
                Db.SaveOrUpdate(setting);

                return RedirectToAction("Logon", "Account");
            }

            return RedirectToAction("List");
        }
コード例 #2
0
        public ActionResult CreateUserAndOAuth(FirstUserViewModel model)
        {
            if (UserService.GetUser(model.Email) == null)
            {
                SettingService.CreateFirstUser(model.Email);

                SettingService.UpdateYandexClientId(model.YandexClientId);
                SettingService.UpdateYandexPassword(model.YandexPassword);

                return RedirectToAction("Logon", "Account");
            }

            return RedirectToAction("List");
        }