public ActionResult EditTags(int? id) { if (!id.HasValue) return RedirectToRoute("Default"); var db = new TagRepository(); var photoDB = new PhotoGalleryRepository(); var tags = db.GetSortedTagListByPhoto(id.Value); var photo = photoDB.GetPhoto(id.Value); if (photo == null) return HttpNotFound(); ViewBag.Title = "Photo Tags - " + photo.FileTitle; var tagsList = new List<string>(); foreach (var tag in tags) { tagsList.Add(tag.TagName); } dynamic model = new ExpandoObject(); model.Photo = photo; model.TagStringToDisplay = String.Join("; ", tagsList.ToArray()); return View("EditTags", model); }
public ActionResult Thumbnail(string id) { var repository = new TagRepository(); var tag = repository.GetTag(id); var photoList = repository.GetPhotoList(id); if (tag != null && photoList.Count > 0) { using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator()) { foreach (var photo in photoList) { using (var imageStream = new System.IO.MemoryStream(photo.FileContents)) { using (var image = System.Drawing.Image.FromStream(imageStream)) { generator.AddImage(image); } } } using (var outStream = new System.IO.MemoryStream()) { generator.WritePngToStream(outStream); var image = new WebImage(outStream); image.Write(); } } return null; } return Redirect("~/Content/Images/gallery-empty.png"); }
public ActionResult Default() { ViewBag.Title = "View All Tags"; var repository = new TagRepository(); var tagsList = repository.GetTagList(); return View(tagsList); }
public ActionResult Get(string id) { ViewBag.Title = "View Tag - " + id; dynamic model = new ExpandoObject(); model.TagName = id; var repository = new TagRepository(); model.Photos = repository.GetPhotos(id); model.SimilarTags = repository.GetSimilarTags(id); return View("View", model); }
public ActionResult EditTags(int id, string newTags) { var photoRepository = new PhotoGalleryRepository(); var tagRepository = new TagRepository(); var photo = photoRepository.GetPhoto(id); if (photo == null) return HttpNotFound(); var tagNames = newTags.Split(';'); tagRepository.DeleteTagsForPhoto(id); foreach (string tagName in tagNames) { var trimmed = tagName.Trim(); bool exists = tagRepository.GetTagCount(trimmed) > 0; if (!exists) tagRepository.InsertTag(trimmed); photoRepository.InsertPhotoTag(id, trimmed); } return RedirectToAction("View", "Photo", new { id = id }); }
public ActionResult View(int? id) { if (!id.HasValue) return RedirectToRoute("Default"); var photoDB = new PhotoGalleryRepository(); var tagDB = new TagRepository(); var userDB = new UserRepository(); var photo = photoDB.GetPhoto(id.Value); if (photo == null) return HttpNotFound(); ViewBag.Title = "Photo - " + photo.FileTitle; dynamic model = new ExpandoObject(); model.Photo = photo; model.User = userDB.GetUserById(photo.UserId); model.Gallery = photoDB.GetGallery(photo.GalleryId); model.Comments = photoDB.GetCommentsByPhoto(photo.Id); model.TagList = tagDB.GetTagListByPhoto(photo.Id); return View("View", model); }