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"); }
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"); }