public ActionResult AddPic(ListingView listpic) { string[] formats = new string[] { ".jpg", ".png", ".gif", ".jpeg" }; Guid id; if (Guid.TryParse(listpic.ListId, out id) && listpic.BaseListing.Picture != null && formats.Any(item => listpic.BaseListing.Picture.FileName.EndsWith(item, StringComparison.OrdinalIgnoreCase))) { Listing list = data.Listings.GetByID(id); if (list != null && list.IsAlive() && list.UserId == WebSecurity.CurrentUserId) { if (listpic.BaseListing.CheckImageValidAndPrep()) { listpic.BaseListing.ProcessPicture(id); } } } return(RedirectToAction("View", new { id = id.StringWithoutDashes() })); }
public ActionResult View(string id) { Guid guid; if (!Guid.TryParse(id, out guid)) { return(RedirectToAction("notfound", "error")); } Listing list = data.Listings.GetByID(guid); if (list == null || !list.IsAlive()) { return(RedirectToAction("notfound", "error")); } var feeds = list.UserProfile.FeedbacksAbout.OrderByDescending(s => s.CreatedDate) .Select(s => new FeedbackView() { Date = s.CreatedDate, Message = s.Message, Score = s.Stars, Username = s.UserFrom.UserName }).Take(5).ToList(); //feeds.Add(new FeedbackView() { Date = DateTime.Now, Username = "******", Score = 4, Message = "Slow delivery" }); //feeds.Add(new FeedbackView() { Date = DateTime.Now, Username = "******", Score = 5, Message = "I thought about it for a while, couldn't decide. but then I did. thanks!" }); //feeds.Add(new FeedbackView() { Date = DateTime.Now, Username = "******", Score = 3, Message = "I thought about it for a while, couldn't decide. but then I did. thanks! I thought about it for a while, couldn't decide. but then I did. thanks! I thought about it for a while, couldn't decide. but then I did. thanks! I thought about it for a while, couldn't decide. but then I did. thanks! sadsad" }); ListingView model = new ListingView() { Category = list.Catagory.Name, Created = list.CreateDate, Description = list.Description, Feedback = feeds, //FeedbackScore = list.UserProfile.SellerScore, ListId = list.ListingId.StringWithoutDashes(), PegCurrency = list.PegCurrency, //Sales = list.UserProfile.FeedbacksAbout.Count, Title = list.Title, //Username = list.UserProfile.UserName, IsApproved = list.IsApproved, UserId = list.UserId, PriceCur = list.PriceCUR, //ActiveBuyerId = list.ActiveEscrowId.HasValue ? list.CurrentEscrow.BuyerId : new Nullable<int>(), //ActiveEscrowId = list.ActiveEscrowId.HasValue ? list.ActiveEscrowId.Value.StringWithoutDashes() : "", PictureCount = 1, BaseListing = null, CurrentUserEscrowId = list.Escrows.Where(s => s.BuyerId == WebSecurity.CurrentUserId && s.ClosedDt == null).Select(s => s.EscrowId.StringWithoutDashes()).FirstOrDefault(), Additions = list.ListingAdditions.ToList(), FeedBadge = new FeedbackBadgeModel() { Sales = list.UserProfile.FeedbacksAbout.Count, Username = list.UserProfile.UserName, Score = list.UserProfile.SellerScore }, FeaturedDate = list.FeaturedDate, OpenTransctions = list.Escrows.Where(s => s.ClosedDt == null).Count(), ExpireDt = list.ExpireDate }; model.PictureCount = list.GetPictureCount(); model.PriceBtc = list.GetPriceBtc(); model.PriceUsd = list.GetPriceUsd(); if (User.Identity.IsAuthenticated) { model.HasContacted = data.ContactMsgs.Get(s => s.ListingId == list.ListingId && s.UserId == WebSecurity.CurrentUserId).FirstOrDefault() != null; } ViewBag.Title = "Viewing: " + model.Title; return(View(model)); }