public ActionResult StudioAdd(StudioAdminViewModel model) { if (ModelState.IsValid) { var api = GoPlayApi.Instance; var studio = new Studio() { name = model.name }; studio.id = api.CreateStudio(studio); if (studio.id > 0) { var studioAssignment = new StudioAdminAssignment() { studio_id = studio.id, game_admin_id = CurrentUser.Id }; api.CreateStudioAdminAssignment(studioAssignment); this.Flash(string.Format("Successfully added studio {0}!", model.name), FlashLevel.Success); return Redirect("/admin/studio/" + studio.id); } this.Flash(string.Format("Failure added studio {0}!", model.name), FlashLevel.Error); } return View(model); }
public bool CreateStudioAdminAssignment(StudioAdminAssignment studioAssignment) { var repo = Repo.Instance; using (var db = repo.OpenConnectionFromPool()) { return repo.CreateStudioAdminAssignment(db, studioAssignment); } }
public bool AssignStudioAdmin(int studio_id, int userId, params string[] roles) { var repo = Repo.Instance; using (var db = repo.OpenConnectionFromPool()) { var myTrans = db.BeginTransaction(); try { if (repo.CreateAuthAssignmentByRoles(db, userId, roles)) { var studioAssignment = new StudioAdminAssignment() { studio_id = studio_id, game_admin_id = userId }; repo.CreateStudioAdminAssignment(db, studioAssignment); myTrans.Commit(); return true; } myTrans.Rollback(); return false; } catch { myTrans.Rollback(); return false; } } }
public bool CreateStudioAdminAssignment(IDbConnection db, StudioAdminAssignment studioAssignment) { return 1 == db.Execute(@"INSERT INTO studio_admin_assignment( studio_id, game_admin_id) VALUES (@studio_id, @game_admin_id);", studioAssignment); }