public void InsertArtwork(Artwork artwork) { db.Entry(artwork.Artist).State = EntityState.Unchanged; db.Entry(artwork.Category).State = EntityState.Unchanged; db.Artworks.Add(artwork); db.SaveChanges(); }
public ActionResult Create(Artwork artwork) { if (ModelState.IsValid) { var artist = db.Artists.First(x => x.Id == artwork.Artist.Id); var art = (List<ArtworkViewModel>)Session["uploads"]; var artToAdd = new List<Artwork>(); if (art.Count > 0) { foreach (var a in art) { a.Artwork.ForSale = true; a.Artwork.Artist = artist; db.Artworks.Add(a.Artwork); } } db.SaveChanges(); return RedirectToAction("Index"); } return View(artwork); }
public Task <Unit> AddArtwork(Metadata metadata, Artwork artwork) { var parameters = new { artwork.ArtworkKind, metadata.Id, artwork.DateAdded, artwork.DateUpdated, artwork.Path }; return(metadata switch { MovieMetadata => _dbConnection.ExecuteAsync( @"INSERT INTO Artwork (ArtworkKind, MovieMetadataId, DateAdded, DateUpdated, Path) VALUES (@ArtworkKind, @Id, @DateAdded, @DateUpdated, @Path)", parameters) .ToUnit(), ShowMetadata => _dbConnection.ExecuteAsync( @"INSERT INTO Artwork (ArtworkKind, ShowMetadataId, DateAdded, DateUpdated, Path) VALUES (@ArtworkKind, @Id, @DateAdded, @DateUpdated, @Path)", parameters) .ToUnit(), SeasonMetadata => _dbConnection.ExecuteAsync( @"INSERT INTO Artwork (ArtworkKind, SeasonMetadataId, DateAdded, DateUpdated, Path) VALUES (@ArtworkKind, @Id, @DateAdded, @DateUpdated, @Path)", parameters) .ToUnit(), EpisodeMetadata => _dbConnection.ExecuteAsync( @"INSERT INTO Artwork (ArtworkKind, EpisodeMetadataId, DateAdded, DateUpdated, Path) VALUES (@ArtworkKind, @Id, @DateAdded, @DateUpdated, @Path)", parameters) .ToUnit(), _ => Task.FromResult(Unit.Default) });
private void HandleNoMatch(Artwork artwork) { artwork.ReplacementImageCardName = artwork.GameImageCardName; artwork.ReplacementImageFile = _errorImage; artwork.IsMatched = false; _logger.LogInformation(Localization.ErrorNoMatch(artwork.GameImageCardName)); }
void ReleaseDesignerOutlets() { if (Album != null) { Album.Dispose(); Album = null; } if (Artist != null) { Artist.Dispose(); Artist = null; } if (Lyrics != null) { Lyrics.Dispose(); Lyrics = null; } if (Track != null) { Track.Dispose(); Track = null; } if (Artwork != null) { Artwork.Dispose(); Artwork = null; } }
// Update is called once per frame void Update() { if (art != null && art.NeedsRedraw()) { art.ApplyImageProcess(); img = art.GetArtwork(); renderer.material.mainTexture = img; Debug.Log("Image applied"); } if (!PauseMenu.isPaused && Input.GetButtonDown("Fire2")) { img = new Texture2D(width, height, TextureFormat.ARGB32, true); art = new Artwork(); textbox.Text("New image and genome"); } if (!PauseMenu.isPaused && Input.GetButtonDown("Fire1")) { TWEANNGenotype geno = art.GetGenotype(); geno.Mutate(); textbox.Text("Mutating..."); art = new Artwork(geno); } }
public void GetMoreGraffitiForArtwork (Artwork artwork, int startingFrom, Action<bool, bool> callback = null) { this.IsGettingMoreGraffiti = true; this.parseManager.PullGraffitiFromServer(artwork, minDownloadAmount, startingFrom, (bool succeeded, Graffiti[] downloads) => { this.IsGettingMoreGraffiti = false; if (succeeded) { if (downloads.Length == 0) { Debug.Log("Weren't any new ones"); if (callback != null) { callback(true, false); } } else { foreach (Graffiti graffiti in downloads) { this.DownloadedGraffiti[artwork].Add(graffiti); } if (callback != null) { callback(true, true); } } } else { if (callback != null) { callback(false, false); } } }); }
public bool HasGraffitiDownloadedForArtwork (Artwork artwork) { if (this.DownloadedGraffiti[artwork].Count == 0) { return false; } else { return true; } }
private string GetArtworkUrl(Artwork artwork, ArtworkKind artworkKind) { string artworkPath = artwork.Path; int height = artworkKind switch { ArtworkKind.Thumbnail => 220, _ => 440 }; if (artworkPath.StartsWith("jellyfin://")) { artworkPath = JellyfinUrl.ProxyForArtwork(_scheme, _host, artworkPath, artworkKind) .SetQueryParam("fillHeight", height); } else if (artworkPath.StartsWith("emby://")) { artworkPath = EmbyUrl.ProxyForArtwork(_scheme, _host, artworkPath, artworkKind) .SetQueryParam("maxHeight", height); } else { string artworkFolder = artworkKind switch { ArtworkKind.Thumbnail => "thumbnails", _ => "posters" }; artworkPath = $"{_scheme}://{_host}/iptv/artwork/{artworkFolder}/{artwork.Path}.jpg"; } return(artworkPath); }
public void DeleteById(int id) { Artwork artwork = Get(id); artwork.IsActive = false; artworkDAL.Update(artwork); }
protected override void CanvasWillShow (CanvasTransitionContext context = null) { if (context.SendingViewController.CanvasName == "Main") { if (context.Data is Artwork && context.Data != null) { this.artworkBeingGraffitid = context.Data as Artwork; if (artworkBeingGraffitid.Orientation == ArtworkOrientation.Landscape) { HideSubcanvas(portraitCC); ShowSubcanvas(landscapeCC, artworkBeingGraffitid); } else { HideSubcanvas(landscapeCC); ShowSubcanvas(portraitCC, artworkBeingGraffitid); } } else { Debug.LogError("Invalid Artwork data sent to Drawing View"); } } else { if (artworkBeingGraffitid.Orientation == ArtworkOrientation.Landscape) { HideSubcanvas(portraitCC); ShowSubcanvas(landscapeCC); } else { HideSubcanvas(landscapeCC); ShowSubcanvas(portraitCC); } } base.CanvasWillShow(context); }
public async Task <IActionResult> PostArtwork([FromForm] ArtworkData artworkData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var author = await _context.Users.FindAsync(artworkData.IdAuthor); var artwork = new Artwork { Name = artworkData.Name, Author = author, DateOfPublication = DateTime.Now, Description = artworkData.Description, Tags = artworkData.Tags }; if (artworkData.File != null) { using (var binaryReader = new BinaryReader(artworkData.File.OpenReadStream())) { var imageData = binaryReader.ReadBytes((int)artworkData.File.Length); artwork.Art = imageData; } } _context.Artworks.Add(artwork); await _context.SaveChangesAsync(); return(Ok()); }
public void CheckIfFirstAddedArtAlsoIsFirstInViewModel_FirstArtworkMatch() { List <Artwork> listOfArt = new List <Artwork>(); Artwork uniqueArt = new Artwork() { ArtName = "SameName" }; listOfArt.Add(uniqueArt); for (int i = 0; i < 10; i++) { Artwork art = new Artwork() { ArtName = "Test" }; listOfArt.Add(art); } IEnumerable <Artwork> collectiveArt = listOfArt; List <Member> member = new List <Member>(); ArtworkViewModel artworkViewmodel = new ArtworkViewModel(collectiveArt, member); string expected = "SameName"; string actual = artworkViewmodel.CollectiveArt[0].ArtName; Assert.Equal(expected, actual); }
private void ProcessArtwork(Artwork artwork) { var replacementCard = FindSuitableReplacementCard(artwork); artwork.ReplacementImageCardName = replacementCard.GameImageCardName; artwork.ReplacementImageFile = replacementCard.ReplacementImageFile; }
public async Task <ActionResult <Artwork> > CreateArtwork(Artwork artwork) { await _context.Artworks.AddAsync(artwork); _context.SaveChanges(); return(artwork); }
public static Operation Delete(Guid?artworkId) { try { Artwork oldRecord = db.Artworks.FirstOrDefault(a => a.ArtistID == artworkId); if (oldRecord != null) { db.Artworks.Remove(oldRecord); db.SaveChanges(); return(new Operation() { Code = "200", Message = "OK" }); } return(new Operation() { Code = "500", Message = "Not found" }); } catch (Exception e) { return(new Operation() { Code = "500", Message = e.Message }); } }
public Artwork GetACode(Author owner) { try { return(_context.Artwork.First(obj => obj.Owner == owner && obj.Status == Models.Enums.ArtworkStatus.FreeToUse)); } catch { int n = 20; // i < "n" ---> "n" represents total number of codes ownered by the author. var codes = _context.ArtworkCode.Take(n).ToList(); foreach (var code in codes) { _context.ArtworkCode.Remove(code); Artwork artwork = new Artwork(); artwork.Id = code.Id; artwork.Code = code.ArtworkCodeCode; artwork.OwnerID = owner.Id; owner.AddCodeFromPot(artwork); } _context.SaveChanges(); return(_context.Artwork.First(obj => obj.Owner == owner && obj.Status == Models.Enums.ArtworkStatus.FreeToUse)); } }
public ActionResult Likes(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Artwork artwork = db.Artworks.Find(Id); if (artwork == null) { return(HttpNotFound()); } int currentLikes = (int)artwork.Likes; artwork.Likes = currentLikes + 1; if (ModelState.IsValid) { db.Entry(artwork).State = EntityState.Modified; db.SaveChanges(); } artwork = db.Artworks.Find(Id); return(PartialView("_Indexpartial", artwork)); }
void CheckArtwork(Artwork artwork) { if (string.IsNullOrWhiteSpace(artwork.Name) || string.IsNullOrWhiteSpace(artwork.ImageUrl)) { throw new Exception("Eseriniz ve adı boş geçilemez."); } }
public async Task <ArtworkResponse> UpdateArtworkAsync(int id, Artwork artwork) { Artwork existingArtwork = await artworkRepository.FindByIdAsync(id); if (existingArtwork == null) { return(new ArtworkResponse("Artwork does not exist")); } existingArtwork.Name = artwork.Name; existingArtwork.Description = artwork.Description; existingArtwork.ImageUrl = artwork.ImageUrl; try { artworkRepository.Update(existingArtwork); await unitOfWork.CompleteAsync(); return(new ArtworkResponse(existingArtwork)); } catch (Exception ex) { return(new ArtworkResponse($"An error occured while updating artwork {ex.Message}")); } }
protected void idCheck_Click(object sender, EventArgs e) { int id = Convert.ToInt32(artId.Text); var db = new ModelTemaXPContainer(); aw = db.Artworks.Find(id); }
public async Task <IActionResult> PostArtwork([FromBody] Artwork artwork) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Artworks.Add(artwork); try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetArtworks", new { id = artwork.ID }, artwork)); } catch (DbUpdateException dex) { if (dex.InnerException.Message.Contains("IX_")) { ModelState.AddModelError("", "Unable to save: Duplicate Name for works of this type."); return(BadRequest(ModelState)); } else { ModelState.AddModelError("", "Unable to save changes to the database. Try again, and if the problem persists see your system administrator."); return(BadRequest(ModelState)); } } }
public async Task <IActionResult> PutArtwork([FromRoute] int id, [FromBody] Artwork artwork) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != artwork.Id) { return(BadRequest()); } _context.Entry(artwork).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtworkExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected override void CanvasWillShow (CanvasTransitionContext context = null) { if (context.Data is Artwork && context.Data != null) { this.artworkBeingGraffitid = context.Data as Artwork; this.canvasReferenceAspectFitter.aspectRatio = artworkBeingGraffitid.AspectRatio; this.canvasReferenceImage.sprite = artworkBeingGraffitid.DrawingReferenceImage; this.paintingController.referenceArea = canvasReferenceArea; this.paintingController.overrideResolution = true; this.paintingController.overrideHeight = artworkBeingGraffitid.Image.texture.height; this.paintingController.overrideWidth = artworkBeingGraffitid.Image.texture.width; this.paintingController.Reset(); this.submitButton.interactable = false; this.currentBrushSettings = new BrushSettings(paintingController, (Color32)Color.red, Brush.Medium); this.mediumBrushButton.image.sprite = mediumBrushFilledSprite; paintingController.DrawingStateChanged += OnDrawing; } else { Debug.Log(context.SendingViewController.CanvasName); // We go here when we come back from Submit view } colorMenu.alpha = 0; this.paintingController.Show(); base.CanvasWillShow(context); }
private int MUTATION_CYCLES = 12; // maximum mutations per evolution public RoomConfiguration(RoomConfiguration parentRoom, int returnPortalID, int championPortalID, Artwork[] artworksPassed, Sculpture[] sculptures) { ArtGallery ag = ArtGallery.GetArtGallery(); Artwork champion = artworksPassed[championPortalID]; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Creating a new room with " + artworksPassed.Length + " artworks"); } this.parentRoom = parentRoom; rooms = new RoomConfiguration[artworksPassed.Length]; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Clearing artworks and sculptures..."); } artworks = new Artwork[artworksPassed.Length]; this.sculptures = sculptures; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Created new artworks: " + artworksPassed.Length); } rooms[returnPortalID] = parentRoom; // clone champion to each artwork and mutate for (int i = 0; i < artworksPassed.Length; i++) { TWEANNGenotype geno = new TWEANNGenotype(champion.GetGenotype().Copy()); // champion art if (i == championPortalID) { //do little geno.Mutate(); } // return art else if (i == returnPortalID) { // do nothing - save some cpu } else { // all other art TWEANNCrossover cross = new TWEANNCrossover(false) { Sucessful = false }; //HACK PROTOTYPE hardcoded value //TWEANNGenotype crossedGeno = cross.Crossover(new TWEANNGenotype(geno.Copy()), new TWEANNGenotype(champion.GetGenotype().Copy())); //geno = crossedGeno; for (int m = 0; m < Random.Range(2, ag.artworkMutationChances); m++) { geno.Mutate(); } } artworks[i] = new Artwork(geno); } MutateSculptures(); }
public Artwork MapPresentationObjectToDataObject(ArtworkViewModel presentationViewModelObject) { Artwork DataModel = new Artwork(); DataModel.ArtworkID = presentationViewModelObject.ArtWorkID; DataModel.AssetNumber = presentationViewModelObject.AssetNumber; DataModel.ArtTitle = presentationViewModelObject.ArtTitle; DataModel.ArtTypeID = presentationViewModelObject.ArtTypeID; DataModel.ArtistID = presentationViewModelObject.ArtistID; DataModel.CountryID = presentationViewModelObject.CountryID; DataModel.VendorID = presentationViewModelObject.VendorID; DataModel.DateCreate = presentationViewModelObject.DateCreated; DataModel.DatePurchased = presentationViewModelObject.DatePurchased; DataModel.CurrentLocationID = presentationViewModelObject.CurrenTLocation; DataModel.Image = presentationViewModelObject.Photo; DataModel.PurchasePrice = presentationViewModelObject.PurchasePrice; //if (presentationViewModelObject.Image != null) //{ // //System.IO.BinaryReader b = new System.IO.BinaryReader(presentationViewModelObject.Image.InputStream); // //byte[] binData = b.ReadBytes(presentationViewModelObject.Image.ContentLength); // //presentationViewModelObject.Image = binData; // //using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) // //{ // // var imageData = presentationViewModelObject.Image.InputStream; // // var length = Convert.ToInt32(imageData.Length); // // byte[] tempImage = new byte[length]; // // imageData.Read(tempImage, 0, length); // // DataModel.Image = tempImage; // //} // DataModel.Image = presentationViewModelObject.Photo; // string extension = System.IO.Path.GetExtension(presentationViewModelObject.Image.FileName); // DataModel.FileExtension = extension; //} DataModel.Levels = presentationViewModelObject.LevelID; DataModel.Section = presentationViewModelObject.SectionID; if (presentationViewModelObject.Photo != null) { DataModel.Image = presentationViewModelObject.Photo; } if (!string.IsNullOrEmpty(presentationViewModelObject.fileExtension)) { DataModel.FileExtension = presentationViewModelObject.fileExtension; } DataModel.PhysicalDimension = presentationViewModelObject.PhysicalDimension; DataModel.Comments = presentationViewModelObject.Comments; return(DataModel); }
public ActionResult DeleteConfirmed(short id) { Artwork artwork = db.Artworkz.Find(id); db.Artworkz.Remove(artwork); db.SaveChanges(); return(RedirectToAction("Inventory")); }
public void ArtworkTestInitialize() { Console.Out.Write("ArtworkTestInitialize called..."); _artworkRepository = new ArtworkRepository(); _artistRepository = new ArtistRepository(); _categoryRepository = new CategoryRepository(); _artwork = new Artwork(); }
public ActionResult DeleteConfirmed(int id) { Artwork artwork = _artworkService.GetArtwork(id); _artworkService.DeleteArtwork(artwork); _artworkService.SaveArtwork(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Artwork artwork = unit.Artworks.GetById(id); unit.Artworks.Delete(artwork.Id); unit.Save(); return(RedirectToAction("Index")); }
private void SwapAlternateImages(Artwork artwork, FileInfo orgImageFile, FileInfo newImageFile) { var altImages = artwork.AlternateReplacementImages; altImages.Remove(newImageFile); altImages.Add(orgImageFile); artwork.AlternateReplacementImages = altImages; }
public ActionResult DeleteConfirmed(int id) { Artwork artwork = db.Artworks.Find(id); db.Artworks.Remove(artwork); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult fav(int rating) { Artwork a = (Artwork)TempData["buyartwork"]; db.addFav(a.AW_CODE, db.GetUserName(User.Identity.Name), rating); return(RedirectToAction("index", "home")); }
private void PopulateDropDownLists(Artwork artwork = null) { ViewBag.ArtistID = new SelectList(db.Artists .OrderBy(a => a.LastName) .ThenBy(a => a.FirstName), "ID", "FormalName", artwork?.ArtistID); ViewBag.ArtTypeID = new SelectList(db.ArtTypes .OrderBy(t => t.Type), "ID", "Type", artwork?.ArtTypeID); }
public ActionResult DeleteConfirmed(int id) { Artwork artwork = db.Artworks.Include(x => x.Artist).Include(x => x.ArtworkType).First(x => x.Id == id); db.Artworks.Remove(artwork); db.SaveChanges(); return(RedirectToAction("Index")); }
public Graffiti (string imageUrl, Artwork originalArt, string title, string poster, string[] likes, string parseId) { this.originalArtwork = originalArt; this.Title = title; this.Poster = poster; this.Likes = likes; this.ParseId = parseId; this.ImageUrl = imageUrl; this.IsDownloaded = false; }
public Graffiti (Sprite image, Artwork originalArt, string title, string poster, string[] likes, string parseId) { this.originalArtwork = originalArt; this.Title = title; this.Poster = poster; this.Likes = likes; this.ParseId = parseId; this.Image = image; this.IsDownloaded = true; }
protected override void CanvasWillShow (CanvasTransitionContext context) { if (context.Data is Artwork && context.Data != null) { this.trackedArtwork = context.Data as Artwork; CrossFadeCanvasGroup(graffitiInfoUI, 0, 0); this.ShowFirstGraffitiForArtwork(this.trackedArtwork); } else { Debug.LogError("Invalid Artwork data sent to Tracking View Controller"); } graffitiInfoUI.alpha = 0; swipeInput.StartChecking(); this.ShowSubcanvas(augmentVC, trackedArtwork); base.CanvasWillShow(context); }
public ActionResult Edit(Artwork artwork) { if (ModelState.IsValid) { ActionConfirmation<Artwork> confirmation = _artworkTasks.SaveOrUpdate(artwork); if (confirmation.WasSuccessful) { TempData["message"] = confirmation.Message; return RedirectToAction("Index"); } ViewData["message"] = confirmation.Message; } return View(_artworkTasks.CreateEditViewModel(artwork)); }
protected override void CanvasWillShow (CanvasTransitionContext context) { if (context.Data is Artwork && context.Data != null) { this.trackedArtwork = context.Data as Artwork; ResizeForArtwork(trackedArtwork); } else { Debug.LogError("Invalid Artwork data sent to Tracking View Controller"); } base.CanvasWillShow(context); this.foundText.CrossFadeAlpha(0, 0, true); this.noGraffitiText.CrossFadeAlpha(0, 0, true); this.graffitiImage.CrossFadeAlpha(0, 0, true); this.networkErrorText.CrossFadeAlpha(0, 0, true); foundText.rectTransform.localScale = new Vector3(1, 1, 1); nonStartedTrackingAnimationCG.alpha = 0; StartCoroutine(ShowStartedTrackingAnimation()); }
public ArtworkControllerModel(ArtworkDBContext db, Artwork artwork) : this(db) { ID = artwork.ID; Title = artwork.Title; Image = artwork.Image; Description = artwork.Description; Height = artwork.Height; Width = artwork.Width; Price = artwork.Price; Quantity = artwork.Quantity; SelectedCategoryId = artwork.Category.CategoryID; SelectedStyleId = artwork.Style.StyleID; artwork.GiftTypes.ToList().ForEach(x => GiftTypes.Add(x)); }
protected override void InitCanvas () { this.AddSubcanvas(trackingVC); this.AddSubcanvas(searchingVC); Events.TrackingStarted += (object sender, TrackingEventArgs e) => { this.isTracking = true; this.trackedArtwork = e.Artwork; if (this.IsShowing) { this.HideSubcanvas(searchingVC, SubcanvasHideStyle.FadeOut, null); this.ShowSubcanvas(trackingVC, this.trackedArtwork); } }; Events.TrackingEnded += (object sender, TrackingEventArgs e) => { this.isTracking = false; this.trackedArtwork = null; if (this.IsShowing) { this.HideSubcanvas(trackingVC); this.ShowSubcanvas(searchingVC, SubcanvasShowStyle.FadeIn, null); } }; }
public ActionResult Upload() { var latestFile = new Artwork(); var vm = new ArtworkViewModel(); for (int i = 0; i < Request.Files.Count; i++) { var existingBlobs = (List<ArtworkViewModel>)Session["uploads"] ?? new List<ArtworkViewModel>(); var file = Request.Files[i]; BinaryReader b = new BinaryReader(file.InputStream); byte[] binData = b.ReadBytes(file.ContentLength); var thumbnail =new byte[0]; byte[] resizedImage; var size = ImageResizer.GetHeightAndWidth(binData); var orientation = ImageResizer.GetOrientation(binData); if (orientation == "landscape") { thumbnail = ImageResizer.ResizeJpg(binData, 270, 200); } else { thumbnail = ImageResizer.ResizeJpgFixedWidth(binData, 270); thumbnail = ImageResizer.CropJpg(thumbnail, new Rectangle(0, 0, 270, 200)); //now crop } //need to make sure it's not too big if (size.Width > 1024) { binData = ImageResizer.ResizeJpgFixedWidth(binData, 1024); } latestFile = new Artwork { FileName = file.FileName.Split('.')[0], Extension = "." + file.FileName.Split('.')[1], Bytes = binData, ResizedBytes = thumbnail, WhenCreated = DateTime.Now, Orientation = orientation, ForSale = true }; Session["uploads"] = existingBlobs; if (Session["uploadsCount"] == null) { Session["uploadsCount"] = 0; } else { var existingCount = (int)Session["uploadsCount"]; Session["uploadsCount"] = existingCount++; } vm = new ArtworkViewModel { Artwork = latestFile, Count = (int)Session["uploadsCount"] }; existingBlobs.Add(vm); Session["uploads"] = existingBlobs; } return Json("Ok"); }
public ActionResult Edit(Artwork artwork) { var previous = db.Artworks.Find(artwork.Id); previous.Description = artwork.Description; previous.Title = artwork.Title; previous.Price = artwork.Price; previous.Material = artwork.Material; previous.Size = artwork.Size; previous.ArtworkType = new ArtworkType { Id = artwork.ArtworkType.Id }; if (ModelState.IsValid) { db.Entry(previous).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(artwork); }
private void LoadXml(string file) { xmlDoc = new XmlDocument(); TextAsset xmlAsset = (TextAsset) Resources.Load(file); xmlDoc.LoadXml(xmlAsset.text); languagesNode = xmlDoc.GetElementsByTagName("sprachen") .Item(0).ChildNodes; artworksNode = xmlDoc.GetElementsByTagName("kunstwerke").Item(0).ChildNodes; gamesNode = xmlDoc.GetElementsByTagName("minispiele").Item(0).ChildNodes; maxTipps = int.Parse(xmlDoc.GetElementsByTagName("maxTipps").Item(0).InnerText); PlayerPrefs.SetInt("LanguagesCount", getLanguages().Length); artworks = new Artwork[artworksNode.Count]; for(int i = 0; i < artworksNode.Count; i++) { artworks[i] = new Artwork(artworksNode.Item(i).ChildNodes); } games = new Games[gamesNode.Count]; for(int i = 0; i < gamesNode.Count; i++) { games[i] = new Games(gamesNode.Item(i).ChildNodes); } }
public void SubmitNewGraffiti (Texture2D image, Artwork originalArt, string title, string poster, Action<bool, Graffiti> callback = null) { this.parseManager.PushNewGraffitiToServer(image, originalArt, title, poster, callback); }
private void ResizeForArtwork (Artwork artwork) { Vector2 newSize = artwork.ImageTarget.SizeInScene; float yScale = newSize.y / this.rectTransform.sizeDelta.y; float xScale = newSize.x / this.rectTransform.sizeDelta.x; this.rectTransform.localScale = new Vector3(xScale, yScale, 1); }
public void PullGraffitiFromServer (Artwork originalArt, int numberOfPosts, int startingFrom = 0, Action<bool, Graffiti[]> callback = null) { StartCoroutine(this.PullGraffitiFromServerCoroutine(originalArt, numberOfPosts, startingFrom, callback)); }
private IEnumerator PullGraffitiFromServerCoroutine (Artwork originalArt, int numberOfPosts, int startingFrom, Action<bool, Graffiti[]> callback) { var query = ParseObject.GetQuery("Graffiti") .WhereEqualTo("originalArtId", originalArt.Id) .Limit(numberOfPosts) .Skip(startingFrom) .OrderBy("createdAt"); var queryTask = query.FindAsync(); while (!queryTask.IsCompleted) { yield return new WaitForEndOfFrame(); } if (!queryTask.IsFaulted) { Debug.Log("Parse call was successful!"); IEnumerable<ParseObject> results = queryTask.Result; List<Graffiti> graffitiArray = new List<Graffiti>(); foreach (ParseObject graffitiPacket in results) { string imageUrl = graffitiPacket.Get<ParseFile>("image").Url.AbsoluteUri; string poster = graffitiPacket.Get<string>("poster"); string title = graffitiPacket.Get<string>("title"); IList<object> likes = graffitiPacket.Get<IList<object>>("likes"); string[] likesArray = new string[likes.Count]; int index = 0; foreach (string like in likes) { likesArray[index] = like; index++; } Graffiti graffiti = new Graffiti(imageUrl, originalArt, title, poster, likesArray, graffitiPacket.ObjectId); downloadManager.QueueDownloadForGraffiti(graffiti); graffitiArray.Add(graffiti); } if (callback != null) { callback(true, graffitiArray.ToArray()); } } else { Debug.LogError("Network error"); if (callback != null) { callback(false, null); } } }
public Artwork GetArtwork(ArtworkDBContext db) { Artwork artwork = new Artwork(); artwork.ID = ID; artwork.Title = Title; artwork.Image = Image; artwork.Description = Description; artwork.Height = Height; artwork.Width = Width; artwork.Price = Price; artwork.Quantity = Quantity; artwork.Style = db.Styles.ToList().Find(x => x.StyleID == SelectedStyleId); artwork.Category = db.Categories.ToList().Find(x => x.CategoryID == SelectedCategoryId); GiftTypes.ToList().ForEach(x => artwork.GiftTypes.Add(x)); return artwork; }
public void ShowFirstGraffitiForArtwork (Artwork artwork) { //TODO: Get this to check for the total amount of art, since this exists now. //TODO: Start out with everything transparent/off. canShowNextArt = false; this.HideChevron(Direction.Left); this.HideChevron(Direction.Right); // First, we check if there is already graffiti downloaded locally to show. if (this.graffitiManager.HasGraffitiDownloadedForArtwork(this.trackedArtwork)) { this.downloadedGraffitiForTrackedArtwork = this.graffitiManager.DownloadedGraffiti[trackedArtwork]; if (this.downloadedGraffitiForTrackedArtwork.Count == 1) { this.canShowNextArt = false; this.HideChevron(Direction.Right); } else { this.canShowNextArt = true; this.ShowChevron(Direction.Right); } Graffiti graffiti = this.downloadedGraffitiForTrackedArtwork[0]; this.shownGraffiti = graffiti; this.titleText.text = graffiti.Title; this.posterText.text = "- " + graffiti.Poster; this.likeButton.transform.Find("Text").GetComponent<Text>().text = graffiti.Likes.Length.ToString(); CrossFadeCanvasGroup(graffitiInfoUI, 1, 0.5f); this.augmentVC.ShowGraffiti(graffiti); } // If there isn't, we ask the graffiti manager if there is more online. else { this.graffitiManager.GetMoreGraffitiForArtwork(this.trackedArtwork, 0, (bool succeeded, bool wasMore) => { if (succeeded) { // If there was more, change the UI stuff and tell the augmented view controller to change its image. if (wasMore) { this.downloadedGraffitiForTrackedArtwork = this.graffitiManager.DownloadedGraffiti[trackedArtwork]; if (this.downloadedGraffitiForTrackedArtwork.Count == 1) { this.canShowNextArt = false; this.HideChevron(Direction.Right); } else { this.canShowNextArt = true; this.ShowChevron(Direction.Right); } Graffiti graffiti = this.downloadedGraffitiForTrackedArtwork[0]; this.shownGraffiti = graffiti; this.titleText.text = graffiti.Title; this.posterText.text = graffiti.Poster; this.likeButton.transform.Find("Text").GetComponent<Text>().text = graffiti.Likes.Length.ToString(); CrossFadeCanvasGroup(graffitiInfoUI, 1, 0.5f); this.augmentVC.ShowGraffiti(graffiti); } // If there wasn't, change the UI to let the user know. else { CrossFadeCanvasGroup(graffitiInfoUI, 0, 0); this.augmentVC.ShowNoGraffitiText(); } } else { this.augmentVC.ShowNetworkErrorText(); } }); } }
public void PushNewGraffitiToServer (Texture2D image, Artwork originalArt, string title, string poster, Action<bool, Graffiti> callback = null) { StartCoroutine(this.PushNewGraffitiToServerCoroutine(image, originalArt, title, poster, callback)); }
private IEnumerator PushNewGraffitiToServerCoroutine (Texture2D image, Artwork originalArt, string title, string poster, Action<bool, Graffiti> callback) { // Begin by encoding the image to PNG and saving that to the server. byte[] data = image.EncodeToPNG(); var imageFile = new ParseFile("image.png", data); Task imageSaveTask = imageFile.SaveAsync(); while (!imageSaveTask.IsCompleted) { yield return new WaitForEndOfFrame(); } // Once that has saved, construct the Graffiti ParseObject and save that. if (!imageSaveTask.IsFaulted) { ParseObject graffitiPO = new ParseObject("Graffiti"); graffitiPO["image"] = imageFile; graffitiPO["originalArtId"] = originalArt.Id; graffitiPO["poster"] = poster; graffitiPO["title"] = title; graffitiPO["likes"] = new string[0]; Task graffitiSaveTask = graffitiPO.SaveAsync(); while (!graffitiSaveTask.IsCompleted) { yield return new WaitForEndOfFrame(); } if (!graffitiSaveTask.IsFaulted) { // Once that has saved, get the affiliated Artwork ParseObject. ParseQuery<ParseObject> query = ParseObject.GetQuery("Artwork") .WhereEqualTo("objectId", originalArt.Id); var queryTask = query.FirstAsync(); while (!queryTask.IsCompleted) { yield return new WaitForEndOfFrame(); } if (!queryTask.IsFaulted) { // Once that has been retrieved, update it. ParseObject artworkPO = queryTask.Result; artworkPO.Increment("NumberOfGraffiti"); var graffitiRelation = artworkPO.GetRelation<ParseObject>("Graffiti"); graffitiRelation.Add(graffitiPO); var artworkUpdateTask = artworkPO.SaveAsync(); while (!artworkUpdateTask.IsCompleted) { yield return new WaitForEndOfFrame(); } if (!artworkUpdateTask.IsFaulted) { // And finally, once the Artwork has been successfully updated, we can finish. Rect rect = new Rect(0, 0, image.width, image.height); Sprite imageSprite = Sprite.Create(image, rect, new Vector2(0.5f, 0.5f)); Graffiti graffiti = new Graffiti(imageSprite, originalArt, title, poster, new string[0], graffitiPO.ObjectId); if (callback != null) { callback(true, graffiti); } } else { Debug.LogError("Network error"); if (callback != null) { callback(false, null); } } } } else { Debug.LogError("Network error"); if (callback != null) { callback(false, null); } } } else { Debug.LogError("Network error"); if (callback != null) { callback(false, null); } } }
public TrackingEventArgs (Artwork artwork) { this.Artwork = artwork; }