Exemplo n.º 1
0
        public List <Image> GetUnprocessedImages(ImageOwner owner, long entityId)
        {
            GetUnprocessedImagesCommand getUnprocessedImagesCommand = new GetUnprocessedImagesCommand(owner, entityId);

            getUnprocessedImagesCommand.Execute();
            return(getUnprocessedImagesCommand.CommandResult);
        }
Exemplo n.º 2
0
 public ActionResult AddComment(ImageOwner io)
 {
     Comment addition = new Comment();
     ViewBag.imgown = io;
     addition.OwnerID = io.OwnerID;
     addition.ImageID = io.OwnerID;
     addition.ImageOwner = io;
     return View(addition);
 }
Exemplo n.º 3
0
        public ActionResult AddComment(ImageOwner io)
        {
            Comment addition = new Comment();

            ViewBag.imgown      = io;
            addition.OwnerID    = io.OwnerID;
            addition.ImageID    = io.OwnerID;
            addition.ImageOwner = io;
            return(View(addition));
        }
Exemplo n.º 4
0
        public ImageOwnerViewModel AddOwner(ImageOwnerViewModel viewModel)
        {
            var owner = new ImageOwner()
            {
                OwnerName     = viewModel.OwnerName,
                OwnerImageUrl = viewModel.OwnerImageUrl
            };

            _dbContext.ImageOwners.Add(owner);
            _dbContext.SaveChanges();

            return(viewModel);
        }
Exemplo n.º 5
0
        internal static ImageVm MapToImageVm(this Image image, ImageOwner owner, string alt)
        {
            ImageVm imageVm = new ImageVm();

            if (image != null)
            {
                imageVm.Src          = image.Url;
                imageVm.ThumbnailSrc = image.ThumbnailUrl;
            }
            imageVm.Alt   = alt;
            imageVm.Owner = owner;
            return(imageVm);
        }
Exemplo n.º 6
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);
     }
 }
Exemplo n.º 7
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));
 }
Exemplo n.º 8
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);
     }
 }
Exemplo n.º 9
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));
 }
Exemplo n.º 10
0
        private ImageOwner GetImageOwner(JToken photo)
        {
            var owner = new ImageOwner()
            {
                OwnerName     = photo.Value <string>("ownername"),
                OwnerImageUrl = "http://c1.staticflickr.com/"
                                + photo.Value <string>("farm")
                                + "/"
                                + photo.Value <string>("server")
                                + "/buddyicons/"
                                + photo.Value <string>("owner")
                                + "_l.jpg"
            };

            return(owner);
        }
Exemplo n.º 11
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());
        }
Exemplo n.º 12
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));
 }
Exemplo n.º 13
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"));
        }
Exemplo n.º 14
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;
     }
 }
Exemplo n.º 15
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;
            }
        }
Exemplo n.º 16
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"));
        }
Exemplo n.º 17
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));
        }
Exemplo n.º 18
0
 public void ProcessImages(ImageOwner owner, long ownerId)
 {
     this.ProcessImages(this._processingDac.GetUnprocessedImages(owner, ownerId));
 }
Exemplo n.º 19
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"));
        }
Exemplo n.º 20
0
 public GetUnprocessedImagesCommand(ImageOwner owner, long entityId)
 {
     this._owner              = owner;
     this._entityId           = entityId;
     base.StoredProcedureName = AdminStoredProcedures.SpGetUnprocessedImages;
 }