public async Task <IActionResult> PutTagPhoto(int id, TagPhoto tagPhoto) { if (id != tagPhoto.IDTagPhoto) { return(BadRequest()); } _context.Entry(tagPhoto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagPhotoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TagPhoto> > PostTagPhoto(TagPhoto tagPhoto) { _context.tagPhotos.Add(tagPhoto); await _context.SaveChangesAsync(); // return CreatedAtAction("GetTagPhoto", new { id = tagPhoto.IDTagPhoto }, tagPhoto); return(CreatedAtAction(nameof(GetTagPhoto), new { id = tagPhoto.IDTagPhoto }, tagPhoto)); }
public string Construct(TagPhoto tagPhoto) { if (tagPhoto is null) { return(null); } return($"{_currentDomain}/Resources/Photo/Tag/{HttpUtility.ParseQueryString(tagPhoto.AdditionalInformation)["Name"]}"); }
public void InvalidationOfSomethingOnALinkTableInvalidatesSet() { Caching.Instances.Main.FlushAll(); Tag tag = new Tag() { TagText = "hello" }; tag.Update(); Photo photo = new Photo(); photo.Update(); Q where = new Q(TagPhoto.Columns.Disabled, false); Assert.AreEqual(0, tag.ChildPhotos(where).Count); TagPhoto tagPhoto = new TagPhoto() { PhotoK = photo.K, TagK = tag.K, Disabled = false}; tagPhoto.Update(); Assert.AreEqual(1, tag.ChildPhotos(where).Count); tagPhoto.Disabled = true; tagPhoto.Update(); Assert.AreEqual(0, tag.ChildPhotos(where).Count); }
public void LinkTablesWork() { //return; Caching.Instances.Main.FlushAll(); Tag tag = new Tag() { TagText = "hello" }; tag.Update(); List<Photo> photos = new List<Photo>(); for (int i = 0; i < 3; i++) { Photo photo = new Photo(); photo.Update(); photos.Add(photo); } for (int i = 0; i < photos.Count; i++) { Assert.AreEqual(i, tag.ChildPhotos().Count); TagPhoto tagPhoto = new TagPhoto() { PhotoK = photos[i].K, TagK = tag.K }; tagPhoto.Update(); } Assert.AreEqual(photos.Count, tag.ChildPhotos().Count); }