// GET: Admin/Works public ActionResult Index() { Covers covers = db.Covers.FirstOrDefault(c => c.Page == "Works"); string cover = ""; if (covers != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "Works").Photo; } else { cover = null; } WorksViewModel model = new WorksViewModel() { Portfolio = new Portfolio(), Portfolios = db.Portfolio.ToList(), Cover = cover, Header = "Create new Portfolio", Action = "Create" }; return(View(model)); }
public IgdbApi(UpdatableAppSettings settings) { this.settings = settings; requestLimiterHandler = TimeLimiter .GetFromMaxCountByInterval(4, TimeSpan.FromSeconds(1)) .AsDelegatingHandler(); HttpClient = new HttpClient(requestLimiterHandler); HttpClient.DefaultRequestHeaders.Add("Accept", "application/json"); CacheRoot = settings.Settings.IGDB.CacheDirectory; if (!Path.IsPathRooted(CacheRoot)) { CacheRoot = Path.Combine(Paths.ExecutingDirectory, CacheRoot); } Games = new Games(this); AlternativeNames = new AlternativeNames(this); InvolvedCompanies = new InvolvedCompanies(this); Genres = new Genres(this); Websites = new Websites(this); GameModes = new GameModes(this); PlayerPerspectives = new PlayerPerspectives(this); Covers = new Covers(this); Artworks = new Artworks(this); Screenshots = new Screenshots(this); AgeRatings = new AgeRatings(this); Collections = new Collections(this); }
// GET: Admin/Works public ActionResult Index() { Covers covers = db.Covers.FirstOrDefault(c => c.Page == "Contact"); Company comp = db.Company.FirstOrDefault(); string cover = ""; string action = ""; Company company; if (covers != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "Contact").Photo; } else { cover = null; } if (comp == null) { action = "Create"; company = new Company(); } else { action = "Edit"; company = comp; } CompanyViewModel model = new CompanyViewModel() { Company = company, Cover = cover, Action = action }; return(View(model)); }
// GET: Admin/Works/Edit/5 public ActionResult Edit(int id) { var team = db.Team.FirstOrDefault(p => p.id == id); Covers covers = db.Covers.FirstOrDefault(c => c.Page == "About"); string cover = ""; if (covers != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "About").Photo; } else { cover = null; } if (team != null) { TeamViewModel model = new TeamViewModel() { Team = team, Teams = db.Team.ToList(), Cover = cover, Header = "Edit Team member", Action = "Edit" }; return(View("Index", model)); } else { return(RedirectToAction("Index")); } }
public void updateCoverDetails(int iNewCoverId, bool xIsNew) { Covers cover = getCover(iNewCoverId); if (cover != null) { if (!xIsNew) // Do not copy name, comment and code to current class when a class is copied. { iCoverId = cover.coverId; sCode.sInput = cover.code; } sCustomer.sInput = cover.customer; sProgram.sInput = cover.program; sManYear.sInput = cover.manyear; sStyle.sInput = cover.style; sColour.sInput = cover.colour; xActive = cover.active; sImagePath = coverImage.checkImagePath(cover.imagePath); } else { emptyCover(); } }
private static Covers Search(string url) { var c = new Covers(); try { var request = WebRequest.Create(url); request.Proxy = WebRequest.DefaultWebProxy; request.Credentials = CredentialCache.DefaultCredentials; ; request.Proxy.Credentials = CredentialCache.DefaultCredentials; var response = request.GetResponse(); var reader = new StreamReader(response.GetResponseStream()); string json = reader.ReadToEnd(); Covers tmp; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(json))) { var settings = new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }; var serializer = new DataContractJsonSerializer(typeof(Covers), settings); tmp = (Covers)serializer.ReadObject(ms); } return tmp ?? c; } catch (Exception) { return c; } }
// GET: Admin/Works public ActionResult Index() { Covers covers = db.Covers.FirstOrDefault(c => c.Page == "About"); string cover = ""; if (covers != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "About").Photo; } else { cover = null; } TeamViewModel model = new TeamViewModel() { Team = new Team(), Teams = db.Team.ToList(), Cover = cover, Header = "Create new Team member", Action = "Create" }; return(View(model)); }
// GET: Admin/Works/Edit/5 public ActionResult Edit(int id) { var service = db.Service.FirstOrDefault(p => p.id == id); if (service != null) { Covers portFolio = db.Covers.FirstOrDefault(c => c.Page == "Service"); string cover = ""; if (portFolio != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "Service").Photo; } else { cover = null; } var model = new ServiceViewModel() { Service = db.Service.FirstOrDefault(s => s.id == id), Services = db.Service.ToList(), Cover = cover, Header = "Edit Service", Action = "Edit" }; return(View("Index", model)); } else { return(RedirectToAction("Index")); } }
private static Covers Search(string url) { var c = new Covers(); try { var request = WebRequest.Create(url); request.Proxy = WebRequest.DefaultWebProxy; request.Credentials = CredentialCache.DefaultCredentials;; request.Proxy.Credentials = CredentialCache.DefaultCredentials; var response = request.GetResponse(); var reader = new StreamReader(response.GetResponseStream()); string json = reader.ReadToEnd(); Covers tmp; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(json))) { var settings = new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }; var serializer = new DataContractJsonSerializer(typeof(Covers), settings); tmp = (Covers)serializer.ReadObject(ms); } return(tmp ?? c); } catch (Exception) { return(c); } }
// GET: Admin/Works/Edit/5 public ActionResult Edit(int id) { var speciality = db.Specialties.FirstOrDefault(p => p.id == id); if (speciality != null) { Covers specCover = db.Covers.FirstOrDefault(c => c.Page == "Specialties"); string cover = ""; if (specCover != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "Specialties").Photo; } else { cover = null; } var model = new SpecViewModel() { Specialy = db.Specialties.FirstOrDefault(s => s.id == id), Specialties = db.Specialties.ToList(), Cover = cover, Header = "Edit Specialty", Action = "Edit" }; return(View("Index", model)); } else { return(RedirectToAction("Index")); } }
// GET: Admin/Works/Edit/5 public ActionResult Edit(int id) { var blog = db.Blog.FirstOrDefault(p => p.id == id); Covers covers = db.Covers.FirstOrDefault(c => c.Page == "Blog"); string cover = ""; if (covers != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "Blog").Photo; } else { cover = null; } if (blog != null) { BlogViewModel model = new BlogViewModel() { Blog = blog, Blogs = db.Blog.ToList(), Cover = cover, Header = "Edit Blog", Action = "Edit" }; return(View("Index", model)); } else { return(RedirectToAction("Index")); } }
public Covers Create(Covers item) { String exception = string.Empty; // validation //if (item.LoginProviderId == 0) // throw new AppException("LoginProviderId is required"); //if (!_context.LoginProvider.Any(lp => lp.Id == item.LoginProviderId && lp.DelFlag == false)) // throw new AppException("LoginProviderId is invalid"); //if (string.IsNullOrWhiteSpace(password) && item.LoginProviderId == (int)LoginProviderEnum.Local) // throw new AppException("Password is required"); //if (string.IsNullOrWhiteSpace(item.UserName)) // throw new AppException("UserName is required"); if (!ValidateRequireField(item, out exception)) { throw new AppException(exception); } if (_context.Covers.Any(x => x.Name == item.Name && x.HealthPlanId == item.HealthPlanId)) { throw new AppException("Cover Name " + item.Name + " is already exists"); } item.CreatedAt = DateTime.Now; _context.Covers.Add(item); _context.SaveChanges(); return(item); }
// GET: Admin/Works public ActionResult Index() { Covers covers = db.Covers.FirstOrDefault(c => c.Page == "Blog"); string cover = ""; if (covers != null) { cover = db.Covers.FirstOrDefault(c => c.Page == "Blog").Photo; } else { cover = null; } BlogViewModel model = new BlogViewModel() { Blog = new Blog(), Blogs = db.Blog.ToList(), Cover = cover, Header = "Create new Blog", Action = "Create" }; return(View(model)); }
/// <summary> /// Updates the tile. Called when the app is initialized and whenever the track changes. /// /// </summary> /// <param name="track">the track, which may be null</param> /// <param name="init">true if this method is called because the app is being initialized, false otherwise</param> /// <returns></returns> public async Task UpdateTileAndBackground(MusicItem track, bool init = false) { try { if (track != null) { await Update(track); var maybeCover = await Covers.TryGetCover(track); if (maybeCover != null) { await SetBackground(maybeCover); } } else { await UpdateNoTrack(); if (init) { var uri = await SetRandomBackground(); //if(uri == null) { // await SetBackground(DefaultBackgroundUri); //} } } } catch (Exception) { // suppresses the exception intentionally, what is the user supposed to do anyway if this fails? // it fails occasionally with some absurd COM Exception message //MessagingService.Instance.Send("Failed to update tile or unable to send toast. " + e.Message); } }
public void PullCoverTest() { Covers test = new Covers(); test = dao.PullCover(123); Assert.AreEqual(123, test.Cover_ID); Assert.AreEqual("testurl.com", test.Cover_Url); }
protected override async Task <bool> LoadAsync() { if (IsLoaded || IsBusy) { return(false); } IsBusy = true; IsBusyText = "Loading Song History..."; await Task.Run(async() => { var randomSetlist = await WebApiClientService.GetSongsAsync(); return(randomSetlist); }) .ContinueWith(task => { try { if (!task.IsFaulted && task.Result != null) { foreach (var song in task.Result.OrderBy(s => s.SongName)) { Songs.Add(song); if (song.IsAlias) { Aliases.Add(song); } if (song.IsCover) { Covers.Add(song); } if (song.IsOriginal) { Originals.Add(song); } } } else { AlertManagerService.ShowAlert("Error Occurred Loading Song History", task.Exception.ToString()); } } catch (Exception e) { AlertManagerService.ShowAlert("Error Occurred Loading Song History", e.ToString()); } finally { IsBusy = false; IsLoaded = true; task.Dispose(); } }, TaskScheduler.FromCurrentSynchronizationContext()); return(true); }
public static DalCover ToDalCover(this Covers cover) { return(new DalCover { ID = cover.CoverID, BookID = cover.BookID, ImagePath = cover.Path }); }
public void FullCoverTest() { dao.PushCover(666, "newurltest.com"); Covers test = new Covers(); test = dao.PullCover(666); Assert.AreEqual(true, dao.CheckCoverValid(666)); Assert.AreEqual(666, test.Cover_ID); Assert.AreEqual("newurltest.com", test.Cover_Url); }
private async Task <IList <Uri> > GetImageCollection() { var images = await Covers.GetCoverCollection(count : 5); if (images.Count == 0) { images.Add(DefaultImageUri); } return(images); }
/// <summary> /// <a href="https://musicbrainz.org/doc/Cover_Art_Archive/API#.2Frelease.2F.7Bmbid.7D.2F" target="_blank">Available Cover Art for a MusicBrainz release</a> /// </summary> /// <param name="mbid">MusicbrainzId</param> /// <example> /// Example shows the typical use of the function /// <code language="vbnet"> /// Dim ret1 = Search.Release("03f9d988-8555-4cdf-afb1-a29c9487bb15") /// </code> /// <code language="c#"> /// var ret1 = Search.Release("03f9d988-8555-4cdf-afb1-a29c9487bb15"); /// </code> /// </example> /// <returns> /// Covers /// </returns> public static Covers Release(string mbid) { Logging.NewLogEntry(new LogEntry("Sites.CoverArtArchive", "Search", "Release", new Para("mbid", mbid))); var ret = new Covers(); try { << << << < HEAD ret.Data = Json.Deserialize <CoversResult>(Http.Request("http://coverartarchive.org/release/" + mbid + "/")) ?? new CoversResult();
public void CoverAddToSQLTest() { IList <GameInfo> testList = new List <GameInfo>(); testList = mediator.GetGames("Halo", false); mediator.PushCoversIntoSQL(testList); Covers test = new Covers(); test = daoCovers.PullCover(55403); Assert.AreEqual(@"https://images.igdb.com/igdb/image/upload/t_cover_big/bcotwv6rapvdglcahxi3.jpg", test.Cover_Url); }
protected async Task <Uri> GetCoverUriOrDefault(MusicItem track) { mutex.WaitOne(); Uri maybeCover = null; try { maybeCover = await Covers.TryGetCover(track); } finally { mutex.ReleaseMutex(); } return(maybeCover != null?PhoneTileUtil.TileUri(maybeCover) : defaultTileUri); }
// Methods :: Public :: RemoveCover /// <summary> /// Remove a cover from the database. /// </summary> /// <param name="key"> /// The album key. /// </param> public void RemoveCover(string key) { lock (this) { if (!Covers.ContainsKey(key)) { return; } db.Delete(key); Covers.Remove(key); } }
protected override void Dispose(bool disposing) { Songs.Clear(); Originals.Clear(); Covers.Clear(); Aliases.Clear(); Songs = null; Originals = null; Covers = null; Aliases = null; base.Dispose(disposing); }
/// <summary> /// Sends a toast notification displaying metadata of the given track. /// </summary> /// <param name="track">track to display in toast notification</param> /// <returns></returns> public override async Task Update(MusicItem track) { Uri maybeCover = await Covers.TryGetCover(track); if (maybeCover != null) { await SetBackground(maybeCover); } var xml = await SetXmlContent(track, maybeCover); SetSilent(xml); Show(xml); }
/// <summary> /// Sets a random album cover as the app background. Opacity 0.1. Does nothing if /// an album cover cannot be found. /// </summary> /// <returns>a Uri to the background which was set, if any, otherwise null</returns> public async Task <Uri> SetRandomBackground() { var covers = await Covers.GetCoverCollection(20); if (covers.Count > 0) { var uri = covers.Head(); await SetBackground(uri); return(uri); } return(null); }
public void PushCoversIntoSQL(IList <GameInfo> games) { //Takes the results from IGDB query and inserts any missing covers into SQL DB foreach (GameInfo x in games) { if (!coverSQLDAO.CheckCoverValid(x.coverID)) { Covers newCover = new Covers(); newCover = coversIGDBDAO.PullCover(x.coverID); coverSQLDAO.PushCover(newCover.Cover_ID, newCover.Cover_Url); } } }
public void SetMovieIds() { if (Covers != null) { Covers.ForEach(c => c.MovieId = Id); } if (Backdrops != null) { Backdrops.ForEach(c => c.MovieId = Id); } if (Posters != null) { Posters.ForEach(c => c.MovieId = Id); } }
public Covers PullCover(int coverId) { //Creates IGDB client using our apiKey var igdb = IGDB.Client.Create(Environment.GetEnvironmentVariable(apiKey)); igdb.ApiKey = apiKey; //Queries IGDB and pulls url based on cover ID that we pull from our game search method var coverImage = Task.Run(() => igdb.QueryAsync <Cover>(IGDB.Client.Endpoints.Covers, query: $"fields *; where id = {coverId};")).Result; Covers newCover = new Covers { Cover_ID = coverId, Cover_Url = @"https://images.igdb.com/igdb/image/upload/t_cover_big/" + $"{coverImage[0].ImageId}.jpg" }; return(newCover); }
public void Delete(Covers item) { var _Covers = _context.Covers.Find(item.Id); if (_Covers != null) { _Covers.UpdatedAt = DateTime.Now; _Covers.DeletedAt = DateTime.Now; _context.Covers.Update(_Covers); _context.SaveChanges(); } else { throw new AppException("Cover not found"); } }
public int saveNewCover() { Covers saveNewCover = new Covers(); saveNewCover.code = sCode.sInput; saveNewCover.customer = sCustomer.sInput; saveNewCover.program = sProgram.sInput; saveNewCover.manyear = sManYear.sInput; saveNewCover.style = sStyle.sInput; saveNewCover.colour = sColour.sInput; saveNewCover.active = xActive; saveNewCover.imagePath = sImagePath; int iNewCoverId = _CoversConnectDB.insertAndSubmit(saveNewCover); return(iNewCoverId); }