コード例 #1
0
        public ActionResult deleteCompleteImage(bool sure, string IDNum, int IDOrig)
        {
            int imageID;

            int.TryParse(IDNum, out imageID);
            if (imageID == IDOrig && sure)
            {
                using (ImageHolderContext ihc = new ImageHolderContext())
                {
                    if (ihc.Flags.Where(x => x.ImageID == IDOrig).Count() >= 1)
                    {
                        try
                        {
                            List <Auction_> AToDelete = new List <Auction_>();
                            AToDelete = ihc.Auction_.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.Auction_.RemoveRange(AToDelete);
                            List <Comment> CToDelete = new List <Comment>();
                            CToDelete = ihc.Comments.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.Comments.RemoveRange(CToDelete);
                            List <Flag> FToDelete = new List <Flag>();
                            FToDelete = ihc.Flags.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.Flags.RemoveRange(FToDelete);
                            List <Purchase> PToDelete = new List <Purchase>();
                            PToDelete = ihc.Purchases.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.Purchases.RemoveRange(PToDelete);
                            List <Like> LToDelete = new List <Like>();
                            LToDelete = ihc.Likes.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.Likes.RemoveRange(LToDelete);
                            List <ImageTag> TToDelete = new List <ImageTag>();
                            TToDelete = ihc.ImageTags.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.ImageTags.RemoveRange(TToDelete);
                            ihc.SaveChanges();
                            List <ImageOwner> IOToDelete = new List <ImageOwner>();
                            IOToDelete = ihc.ImageOwners.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.ImageOwners.RemoveRange(IOToDelete);
                            ihc.SaveChanges();
                            List <Image> IToDelete = new List <Image>();
                            IToDelete = ihc.Images.Where(x => x.ImageID == IDOrig).ToList();
                            ihc.Images.RemoveRange(IToDelete);
                            ihc.SaveChanges();
                            ViewBag.Message = "Success! Image " + IDOrig + " has been deleted!";
                        }
                        catch (Exception e)
                        {
                            ViewBag.Message = "Something went wrong with the deletion: " + e.Message + "\n" + e.InnerException;
                        }
                    }
                    else
                    {
                        ViewBag.Message = "This image isn't flagged, why are you purging it completely?";
                    }
                }
            }
            else
            {
                ViewBag.Message = "You missed the confirmation, such drastic action will not be acted upon without the proper convermation.";
            }
            ViewBag.submitted = true;
            return(View());
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: reticen/PixelJunkie
 public ActionResult MessageCenter()
 {
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         List<Comment> Comments = ihc.Comments.Where(x => x.OwnerID == WebSecurity.CurrentUserId).Select(x => x).ToList();
         return View(Comments);
     }
 }
コード例 #3
0
 public ActionResult MessageCenter()
 {
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         List <Comment> Comments = ihc.Comments.Where(x => x.OwnerID == WebSecurity.CurrentUserId).Select(x => x).ToList();
         return(View(Comments));
     }
 }
コード例 #4
0
ファイル: Notification.cs プロジェクト: reticen/PixelJunkie
 public Notification(Message message)
 {
     PosterID = message.SenderID;
     timeStamp = DateTime.Now;
     type = "MessageNote";
     Content = message.Content;
     title = message.Title;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         userName = Controllers.AccountController.GetNameFromID(PosterID);
     }
 }
コード例 #5
0
ファイル: Notification.cs プロジェクト: reticen/PixelJunkie
 public Notification(Flag flag)
 {
     PosterID = flag.FlaggerID;
     timeStamp = flag.TimeOfFlag;
     Content = flag.Description;
     ImageID = (int)flag.ImageID;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         userName = Controllers.AccountController.GetNameFromID(PosterID);
     }
     type = "flagNote";
 }
コード例 #6
0
ファイル: MessageCenter.cs プロジェクト: reticen/PixelJunkie
 public IEnumerable<Notification> allComments(int userID)
 {
     List<Notification> notes = new List<Notification>();
     using(ImageHolderContext con = new ImageHolderContext())
     {
         foreach(Comment c in con.Comments.Where(x => x.OwnerID == userID).ToList())
         {
             notes.Add(new Notification(c));
         }
         return notes;
     }
 }
コード例 #7
0
 public Notification(Flag flag)
 {
     PosterID  = flag.FlaggerID;
     timeStamp = flag.TimeOfFlag;
     Content   = flag.Description;
     ImageID   = (int)flag.ImageID;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         userName = Controllers.AccountController.GetNameFromID(PosterID);
     }
     type = "flagNote";
 }
コード例 #8
0
 public Notification(Message message)
 {
     PosterID  = message.SenderID;
     timeStamp = DateTime.Now;
     type      = "MessageNote";
     Content   = message.Content;
     title     = message.Title;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         userName = Controllers.AccountController.GetNameFromID(PosterID);
     }
 }
コード例 #9
0
 public ActionResult AddTag(ImageOwner imgOwn, string tag)
 {
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         ImageTag newTag = new ImageTag();
         newTag.ImageID = imgOwn.ImageID;
         newTag.Tag     = tag;
         ihc.ImageTags.Add(newTag);
         ViewBag.message = "Tag successfully added";
         ihc.SaveChanges();
     }
     return(View("DisplayImagePage", imgOwn));
 }
コード例 #10
0
        public IEnumerable <Notification> allLikes(int userID)
        {
            List <Notification> notes = new List <Notification>();

            using (ImageHolderContext con = new ImageHolderContext())
            {
                foreach (Like like in con.Likes.Where(x => x.OwnerID == userID).ToList())
                {
                    notes.Add(new Notification(like));
                }
            }
            return(notes);
        }
コード例 #11
0
        public IEnumerable <Notification> allComments(int userID)
        {
            List <Notification> notes = new List <Notification>();

            using (ImageHolderContext con = new ImageHolderContext())
            {
                foreach (Comment c in con.Comments.Where(x => x.OwnerID == userID).ToList())
                {
                    notes.Add(new Notification(c));
                }
                return(notes);
            }
        }
コード例 #12
0
 public Notification(Like like)
 {
     ImageID   = like.ImageID;
     PosterID  = like.LikerID;
     type      = "LikeNote";
     timeStamp = like.Timestamp;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         imgown   = ihc.ImageOwners.Include("Likes1").Include("Auction_").Include("Comments").Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault();
         title    = ihc.ImageOwners.Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault().Title;
         userName = Controllers.AccountController.GetNameFromID(PosterID);
     }
 }
コード例 #13
0
ファイル: MessageCenter.cs プロジェクト: reticen/PixelJunkie
        public IEnumerable<Notification> allPurchases(int userID)
        {
            List<Notification> notes = new List<Notification>();
            using (ImageHolderContext con = new ImageHolderContext())
            {
                foreach (Purchase own in con.Purchases.Where(x => x.SellerID == userID).ToList())
                {
                    notes.Add(new Notification(own));
                }

            }
            return notes;
        }
コード例 #14
0
ファイル: Notification.cs プロジェクト: reticen/PixelJunkie
 public Notification(Like like)
 {
     ImageID = like.ImageID;
     PosterID = like.LikerID;
     type = "LikeNote";
     timeStamp = like.Timestamp;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         imgown = ihc.ImageOwners.Include("Likes1").Include("Auction_").Include("Comments").Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault();
         title = ihc.ImageOwners.Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault().Title;
         userName = Controllers.AccountController.GetNameFromID(PosterID);
     }
 }
コード例 #15
0
ファイル: HomeController.cs プロジェクト: reticen/PixelJunkie
 public ActionResult SearchTags(string tag)
 {
     List<ImageOwner> imageList = null;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         var imgTags = ihc.ImageTags.Where(x => x.Tag == tag).ToList();
         foreach (ImageTag it in imgTags)
         {
             imageList.Add(ihc.ImageOwners.Where(x => x.ImageID == it.ImageID).First());
         }
     }
     return View("Index", imageList);
 }
コード例 #16
0
        public IEnumerable <Notification> allPurchases(int userID)
        {
            List <Notification> notes = new List <Notification>();

            using (ImageHolderContext con = new ImageHolderContext())
            {
                foreach (Purchase own in con.Purchases.Where(x => x.SellerID == userID).ToList())
                {
                    notes.Add(new Notification(own));
                }
            }
            return(notes);
        }
コード例 #17
0
 public Notification(Purchase purch)
 {
     PosterID  = purch.PurchaserID;
     ImageID   = purch.ImageID;
     timeStamp = purch.TimeOfPurchase;
     Content   = "" + purch.PurchasePrice;
     type      = "PurchaseNote";
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         userName = Controllers.AccountController.GetNameFromID(PosterID);
         title    = ihc.ImageOwners.Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault().Title;
     }
 }
コード例 #18
0
ファイル: MessageCenter.cs プロジェクト: reticen/PixelJunkie
        public IEnumerable<Notification> allLikes(int userID)
        {
            List<Notification> notes = new List<Notification>();
            using (ImageHolderContext con = new ImageHolderContext())
            {
                foreach (Like like in con.Likes.Where(x => x.OwnerID == userID).ToList())
                {
                    notes.Add(new Notification(like));
                }

            }
            return notes;
        }
コード例 #19
0
 public ActionResult DeleteImageID(int imageID)
 {
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         var toDelete = ihc.Images.Where(x => x.ImageID == imageID).FirstOrDefault();
         if (toDelete != null)
         {
             ihc.Images.Remove(toDelete);
             ViewBag.message = "Image successfully deleted";
         }
         ihc.SaveChanges();
     }
     return(RedirectToAction("Index", "Home"));
 }
コード例 #20
0
        public ActionResult SearchTags(string tag)
        {
            List <ImageOwner> imageList = null;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                var imgTags = ihc.ImageTags.Where(x => x.Tag == tag).ToList();
                foreach (ImageTag it in imgTags)
                {
                    imageList.Add(ihc.ImageOwners.Where(x => x.ImageID == it.ImageID).First());
                }
            }
            return(View("Index", imageList));
        }
コード例 #21
0
 public ActionResult DeleteTag(ImageOwner imgOwn, string tag)
 {
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         ImageTag foundTag = ihc.ImageTags.Where(x => x.ImageID == imgOwn.ImageID && x.Tag.Equals(tag)).FirstOrDefault();
         if (foundTag != null)
         {
             ihc.ImageTags.Remove(foundTag);
         }
         ViewBag.message = "Tag successfully deleted";
         ihc.SaveChanges();
     }
     return(View("DisplayImagePage", imgOwn));
 }
コード例 #22
0
        public ActionResult veiwOverallImage()
        {
            int ImageID;

            int.TryParse((String)Url.RequestContext.RouteData.Values["id"], out ImageID);
            Image img = null;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                img            = ihc.Images.Where(x => x.ImageID == ImageID).First();
                ViewBag.owners = ihc.ImageOwners.Include("Comments").Include("Auction_").Include("Likes1").Where(x => x.ImageID == ImageID).ToList();
            }
            return(View(img));
        }
コード例 #23
0
        public ActionResult deleteCompleteImage()
        {
            ViewBag.submitted = false;
            int ImageID;

            int.TryParse((String)Url.RequestContext.RouteData.Values["id"], out ImageID);
            Image toDelete;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                toDelete = ihc.Images.Where(x => x.ImageID == ImageID).FirstOrDefault();
            }
            return(View(toDelete));
        }
コード例 #24
0
 public ActionResult sendMessage(String username, string title, string messageText)
 {
     Message m = new Message();
     m.ReceiverID = WebSecurity.GetUserId(username);
     m.Title = title;
     m.Content = messageText;
     m.SenderID = WebSecurity.CurrentUserId;
     m.TimeStamp = DateTime.Now;
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         ihc.Messages.Add(m);
         ihc.SaveChanges();
     }
     return Redirect("MessageCenter");
 }
コード例 #25
0
        public ActionResult sendMessage(String username, string title, string messageText)
        {
            Message m = new Message();

            m.ReceiverID = WebSecurity.GetUserId(username);
            m.Title      = title;
            m.Content    = messageText;
            m.SenderID   = WebSecurity.CurrentUserId;
            m.TimeStamp  = DateTime.Now;
            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                ihc.Messages.Add(m);
                ihc.SaveChanges();
            }
            return(Redirect("MessageCenter"));
        }
コード例 #26
0
        public ActionResult AddAuction(long startingBid, int auctionDuration, ImageOwner poster)
        {
            DateTime todaysDate = DateTime.Now;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                if (todaysDate < todaysDate.AddDays(auctionDuration))
                {
                    Auction_ auctionToAdd = new Auction_ {
                        CurrentBid = startingBid, ExpirationDate = DateTime.Now.AddDays(auctionDuration), PosterID = poster.OwnerID, ImageID = poster.ImageID
                    };
                    ihc.Auction_.Add(auctionToAdd);
                }
            }
            return(View());
        }
コード例 #27
0
        public IEnumerable <Notification> allFlags()
        {
            List <Notification> notes = new List <Notification>();

            if (Roles.IsUserInRole("Admin"))
            {
                using (ImageHolderContext con = new ImageHolderContext())
                {
                    foreach (Flag f in con.Flags)
                    {
                        notes.Add(new Notification(f));
                    }
                }
            }
            return(notes);
        }
コード例 #28
0
 public ActionResult SingleImage(ImageOwner imgOwn)
 {
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         // byte[] img = ihc.Images.Where(x => x.ImageID == imgOwn.ImageID).FirstOrDefault().Image1;
         var base64 = Convert.ToBase64String(ihc.Images.Where(x => x.ImageID == imgOwn.ImageID).FirstOrDefault().Image1);
         var img    = String.Format("data:image/gif;base64,{0}", base64);
         ViewBag.Image = img;
         List <string> tagList = ihc.ImageTags.Where(x => x.ImageID == imgOwn.ImageID).Select(x => x.Tag).ToList();
         ViewBag.Tags = tagList;
         List <Comment> Comments = ihc.Comments.Where(x => x.ImageID == imgOwn.ImageID && x.OwnerID == imgOwn.OwnerID).Select(x => x).ToList();
         @ViewBag.LikeCount = ihc.Likes.Where(x => x.ImageID == imgOwn.ImageID && x.OwnerID == imgOwn.OwnerID).Select(x => x).Count();
         imgOwn.Comments    = Comments;
         ViewBag.Comments   = Comments;
     }
     return(View(imgOwn));
 }
コード例 #29
0
ファイル: MessageCenter.cs プロジェクト: reticen/PixelJunkie
        public IEnumerable<Notification> allFlags()
        {
            List<Notification> notes = new List<Notification>();
            if(Roles.IsUserInRole("Admin"))
            {

                using (ImageHolderContext con = new ImageHolderContext())
                {
                    foreach (Flag f in con.Flags)
                    {
                        notes.Add(new Notification(f));
                    }

                }

            }
            return notes;
        }
コード例 #30
0
        public ActionResult BuyImage(ImageOwner image)
        {
            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                Models.AccountModels.User oldOwner = AccountController.GetUserFromID(image.OwnerID);
                Models.AccountModels.User newOwner = AccountController.GetUserFromID(WebSecurity.CurrentUserId);

                if (image.Price > 0)
                {
                    if (image.OwnerID != newOwner.Id && newOwner.Id >= image.Price)
                    {
                        oldOwner.Points += (int)image.Price;
                        newOwner.Points -= (int)image.Price;

                        //Purchase purchase = new Purchase { ImageID = image.ImageID, PurchasePrice = image.Price, PurchaserID = newOwner.MemberID, SellerID = oldOwner.MemberID, TimeOfPurchase = DateTime.Now };
                        //ihc.Purchases.Add(purchase);

                        ImageOwner newImageOwner = new ImageOwner()
                        {
                            OwnerID   = WebSecurity.CurrentUserId,
                            ImageID   = image.ImageID,
                            Caption   = image.Caption,
                            Title     = image.Title,
                            TimeStamp = image.TimeStamp,
                            isForSale = false,
                            isAuction = false,
                            Price     = 0
                        };

                        ihc.ImageOwners.Add(newImageOwner);
                        ihc.SaveChanges();
                    }
                }
                else
                {
                    throw new Exception("Price is not greater than 0");
                }

                ihc.SaveChanges();
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #31
0
        public ActionResult Featured()
        {
            List <ImageOwner> imageList = null;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                if (ihc.ImageOwners.ToList().Count > 0)
                {
                    var imgs = from imgown in ihc.ImageOwners.Include("Comments").Include("Auction_") select imgown;
                    imageList = imgs.ToList();
                    foreach (ImageOwner io in imageList)
                    {
                        Image img = ihc.Images.Where(x => x.ImageID == io.ImageID).First();
                        io.Image = img;
                    }
                }
            }
            return(View("Featured", imageList));
        }
コード例 #32
0
ファイル: HomeController.cs プロジェクト: reticen/PixelJunkie
        public ActionResult Index()
        {
            List<ImageOwner> imageList = null;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                if (ihc.ImageOwners.ToList().Count > 0)
                {
                    var imgs = from imgown in ihc.ImageOwners.Include("Comments").Include("Auction_").Include("Likes1") select imgown;
                    imageList = imgs.ToList();
                    foreach (ImageOwner io in imageList)
                    {
                        Image img = ihc.Images.Where(x => x.ImageID == io.ImageID).FirstOrDefault();
                        io.Image = img;
                    }
                }
            }
            return View(imageList);
        }
コード例 #33
0
        public ActionResult removeFlagsOnImage()
        {
            //Should only be available for admin from the image page. When user pages and messages are up there will be a way to delete specific flags
            int ImageID;

            int.TryParse((String)Url.RequestContext.RouteData.Values["id"], out ImageID);
            using (ImageHolderContext con = new ImageHolderContext())
            {
                var imageFlags =
                    from F in con.Flags
                    where F.ImageID == ImageID
                    select F;
                foreach (Flag F in imageFlags)
                {
                    con.Flags.Remove(F);
                }
                con.SaveChanges();
            }
            return(RedirectToAction("Index", "Home"));//Right now this redirects to home, it will redirect back to the image page.
        }
コード例 #34
0
 public Notification(Comment com)
 {
     PosterID  = com.PosterID;
     timeStamp = com.TimeStamp;
     Content   = com.Content;
     ImageID   = com.ImageID;
     type      = "CommentNote";
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         imgown = ihc.ImageOwners.Include("Likes1").Include("Auction_").Include("Comments").Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault();
         try
         {
             userName = Controllers.AccountController.GetNameFromID(PosterID);
         }catch (NullReferenceException nre)
         {
             userName = "******";
         }
         title = ihc.ImageOwners.Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault().Title;
     }
 }
コード例 #35
0
        public ActionResult UpdateBid(ImageOwner image, long bid)
        {
            DateTime todaysDate = DateTime.Now;

            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                Auction_ auction                 = ihc.Auction_.Where(x => x.ImageID == image.ImageID).FirstOrDefault();
                DateTime?expirationDate          = auction.ExpirationDate;
                Models.AccountModels.User bidder = AccountController.GetUserFromID(WebSecurity.CurrentUserId);

                if (todaysDate < expirationDate)
                {
                    if (bidder.Points >= image.Price && bidder.Points >= bid)
                    {
                        auction.CurrentBid = bid;
                        bidder.Points     -= (int)bid;
                    }
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #36
0
        public ActionResult AddComment(Comment com)
        {
            using (ImageHolderContext con = new ImageHolderContext())
            {
                try
                {
                    com.PosterID   = WebSecurity.CurrentUserId;
                    com.TimeStamp  = DateTime.Now;
                    com.ImageOwner = con.ImageOwners.Where(x => (x.ImageID == com.ImageID) && (x.OwnerID == com.OwnerID)).FirstOrDefault();
                    com.ImageOwner.Comments.Add(com);
                    con.Comments.Add(com);
                    con.SaveChanges();
                }
                catch (Exception e)
                {
                    var m = e.Message;
                }

                return(RedirectToAction("SingleImage", "Image", com.ImageOwner));
            }
        }
コード例 #37
0
        public ActionResult AddComment(Comment com)
        {
            using (ImageHolderContext con = new ImageHolderContext())
            {
                try
                {
                    com.PosterID = WebSecurity.CurrentUserId;
                    com.TimeStamp = DateTime.Now;
                    com.ImageOwner = con.ImageOwners.Where(x=> (x.ImageID==com.ImageID) && (x.OwnerID==com.OwnerID)).FirstOrDefault();
                    com.ImageOwner.Comments.Add(com);
                    con.Comments.Add(com);
                    con.SaveChanges();
                }
                catch (Exception e)
                {
                    var m = e.Message;
                }

                return RedirectToAction("SingleImage", "Image", com.ImageOwner);
            }
        }
コード例 #38
0
ファイル: Notification.cs プロジェクト: reticen/PixelJunkie
        public Notification(Comment com)
        {
            PosterID = com.PosterID;
            timeStamp = com.TimeStamp;
            Content = com.Content;
            ImageID = com.ImageID;
            type = "CommentNote";
            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                imgown = ihc.ImageOwners.Include("Likes1").Include("Auction_").Include("Comments").Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault();
                try
                {

                    userName = Controllers.AccountController.GetNameFromID(PosterID);
                }catch(NullReferenceException nre)
                {
                    userName = "******";
                }
                title = ihc.ImageOwners.Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault().Title;
            }
        }
コード例 #39
0
 public ActionResult AddFlag(Flag f)
 {
     using (ImageHolderContext con = new ImageHolderContext())
     {
         f.FlaggerID  = WebSecurity.CurrentUserId;
         f.TimeOfFlag = DateTime.Now;
         int seekID = 0;
         int.TryParse((String)Url.RequestContext.RouteData.Values["id"], out seekID);
         f.ImageID = seekID;
         //    f.Member = con.Members.Where(x => x.MemberID == WebSecurity.CurrentUserId).FirstOrDefault();
         f.Image = con.Images.Where(x => x.ImageID == f.ImageID).FirstOrDefault();
         con.Flags.Add(f);
         try
         {
             con.SaveChanges();
         }
         catch (Exception e)
         {
             var m = e.Message;
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
コード例 #40
0
        public ActionResult LikeImage(ImageOwner imgOwn)
        {
            using (ImageHolderContext ihc = new ImageHolderContext())
            {
                if (ihc.Likes.Where(x => x.ImageID == imgOwn.ImageID && x.OwnerID == imgOwn.OwnerID && x.LikerID == WebSecurity.CurrentUserId).Select(x => x).Count() == 0)
                {
                    Like neolike = new Like();
                    neolike.ImageID   = imgOwn.ImageID;
                    neolike.OwnerID   = imgOwn.OwnerID;
                    neolike.LikerID   = WebSecurity.CurrentUserId;
                    neolike.Timestamp = DateTime.Now;
                    ihc.Likes.Add(neolike);
                    ihc.SaveChanges();
                }

                /* ImageOwner image = ihc.ImageOwners.Where(x => x.ImageID == imgOwn.ImageID && x.OwnerID == imgOwn.OwnerID).FirstOrDefault();
                 * if (image != null)
                 * {
                 *   image.Likes = image.Likes + 1;
                 *   ihc.SaveChanges();
                 * }*/
            }
            return(RedirectToAction("SingleImage", imgOwn));
        }
コード例 #41
0
ファイル: Notification.cs プロジェクト: reticen/PixelJunkie
 public Notification(Purchase purch)
 {
     PosterID = purch.PurchaserID;
     ImageID = purch.ImageID;
     timeStamp = purch.TimeOfPurchase;
     Content = "" + purch.PurchasePrice;
     type = "PurchaseNote";
     using (ImageHolderContext ihc = new ImageHolderContext())
     {
         userName = Controllers.AccountController.GetNameFromID(PosterID);
         title = ihc.ImageOwners.Where(x => x.OwnerID == WebSecurity.CurrentUserId && x.ImageID == ImageID).FirstOrDefault().Title;
     }
 }
コード例 #42
0
        public ActionResult StoreImage(HttpPostedFileBase file, long price, string title, string caption, long startingBid, int daysOfAuction, String listSelection)
        {
            if (file != null)
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    file.InputStream.CopyTo(stream);
                    byte[] imageArray = stream.GetBuffer();
                    if (ModelState.IsValid)
                    {
                        using (ImageHolderContext ihc = new ImageHolderContext())
                        {
                            DateTime time = DateTime.Now;
                            //this is using the test user created in the Index action in home
                            //int ID = 11;
                            int   ID       = WebSecurity.CurrentUserId;
                            Image newImage = new Image();
                            newImage.Image1           = imageArray;
                            newImage.DateOfUpload     = time;
                            newImage.OriginalPosterID = ID;
                            ihc.Images.Add(newImage);
                            ihc.SaveChanges();

                            ImageOwner imgOwn = new ImageOwner();

                            imgOwn.Price = price;

                            if (title != null)
                            {
                                imgOwn.Title = title;
                            }
                            if (caption != null)
                            {
                                imgOwn.Caption = caption;
                            }
                            Image img = ihc.Images.Where(x => x.OriginalPosterID == ID && x.DateOfUpload == time).First();
                            imgOwn.Image   = img;
                            imgOwn.ImageID = img.ImageID;
                            //imgOwn.Member = ihc.Members.Where(x => x.MemberID == ID).First();
                            imgOwn.OwnerID   = ID;
                            imgOwn.TimeStamp = time;
                            if (price > 0)
                            {
                                imgOwn.isForSale = true;
                            }
                            else
                            {
                                imgOwn.isForSale = false;
                            }

                            if (startingBid > 0)
                            {
                                imgOwn.isAuction = true;
                                AddAuction(startingBid, daysOfAuction, imgOwn);
                            }
                            else
                            {
                                imgOwn.isAuction = false;
                            }


                            ihc.ImageOwners.Add(imgOwn);
                            ihc.SaveChanges();
                        }
                        ViewBag.message = "Image successfully added";
                    }
                }
            }
            return(RedirectToAction("Profile/" + WebSecurity.CurrentUserId, "Account"));
        }