public void ListMustBeEmptyOnStartup()
        {
            var list = new Listing<String>();
            var x = list.GetItems();
            var count = x.Count();

            Assert.AreEqual(0,count);
        }
 /*Adds Listing*/
 public void Add(Listing listing)
 {
     using (var db = new ListPlusEntities())
     {
         db.Listings.Add(listing);
         db.SaveChanges();
     }
 }
        public void ItemSoudBeAddedToListIfAddIsCalled()
        {
            var list = new Listing<String>();
            list.Add("Test");
            var count = list.GetItems().Count();

            Assert.AreEqual(1,count);
        }
Пример #4
0
    public FatStream(Listing.FatFile aFile) {
      mFile = aFile;
      mFS = mFile.FileSystem;
      mReadBuffer = mFile.FileSystem.NewClusterArray();

      if (mFile.Size > 0) {
        mFatTable = mFile.GetFatTable();
      }
    }
 /*Deletes Listing*/
 public void Delete(Listing listing)
 {
     using (var db = new ListPlusEntities())
     {
         var lst = db.Listings.Find(listing.Id);
         db.Listings.Remove(lst);
         db.SaveChanges();
     }
 }
        public MoreActionViewModel(Listing<Comment> parent, int indentLevel, FlatCommentCollection listParent) : base()
        {
            _isInProcess = false;
            _parent = parent;
            _indentLevel = indentLevel;
            _listParent = listParent;

            _loadMore = new RelayCommand(LoadMoreAction);
        }
 /*Updates Listing*/
 public void Update(Listing listing)
 {
     using (var db = new ListPlusEntities())
     {
         db.Listings.Attach(listing);
         db.Entry(listing).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
        public void ItemShouldBeRemovedFromListIfRemoveIsCalled()
        {
            var list = new Listing<String>();
            list.Add("Test");
            list.Remove("Test");

            var count = list.GetItems().Count();

            Assert.AreEqual(0, count);
        }
Пример #9
0
 public static void addListingTag(Listing listing, Tag tag)
 {
     SqlConnection conn = DBConnector.getSqlConnection();
     conn.Open();
     SqlCommand cmd = new SqlCommand("INSERT INTO ListingTags (ListingId, TagId) VALUES (@ListingId, @TagId); SELECT SCOPE_IDENTITY()", conn);
     cmd.Parameters.AddWithValue("@ListingId", listing.ListingId);
     cmd.Parameters.AddWithValue("@TagId", tag.id);
     cmd.ExecuteNonQuery();
     conn.Close();
 }
Пример #10
0
 public static void deleteListingTag(Listing listing, Tag tag)
 {
     SqlConnection conn = DBConnector.getSqlConnection();
     conn.Open();
     SqlCommand cmd = new SqlCommand("DELETE FROM ListingTags WHERE ListingId = @ListingID AND TagId = @TagId", conn);
     cmd.Parameters.AddWithValue("@ListingId", listing.ListingId);
     cmd.Parameters.AddWithValue("@TagId", tag.id);
     cmd.ExecuteNonQuery();
     conn.Close();
 }
Пример #11
0
        public ListGump( Mobile m, Listing listing )
            : base(m, 100, 100)
        {
            c_Info = ChatInfo.GetInfo( m );
            c_Listing = listing;

            c_List = new ArrayList();
            c_Mailbox = true;

            NewGump();
        }
 private ArrayList searchTitles(Listing<Post> listing, string keyword, int maxPostsToSearch)
 {
     ArrayList retList = new ArrayList();
     foreach (Post post in listing.Take<Post>(maxPostsToSearch))
     {
         if (post.Title.ToLower().Contains(keyword.ToLower()))
         {
             retList.Add(post);
         }
     }
     return retList;
 }
Пример #13
0
        public FatDirectoryStream(Listing.FatDirectory aDirectory)
        {
            mDirectory = aDirectory;
            mFS = mDirectory.FileSystem;
            if (mFS == null)
            {
                FatHelpers.Debug("mFS is null!");
            }

            if (mDirectory.Size > 0)
            {
                mFatTable = mFS.GetFatTable(mDirectory.FirstClusterNum);
            }
        }
        public void BinarySearchShouldReturnTheCorrectPositionOfItem()
        {
            var list = new Listing<String>();
            list.Add("1");
            list.Add("4");
            list.Add("12");
            list.Add("15");
            list.Add("22");
            list.Add("67");
            list.Add("100");

            var index = list.BinarySearch("22");

            Assert.AreEqual(4,index);
        }
Пример #15
0
    public static Listing addListing(Listing listing)
    {
        SqlConnection conn = DBConnector.getSqlConnection();
        conn.Open();
        SqlCommand cmd = new SqlCommand("INSERT INTO Listing (UserId, Title, Description, Price, Location, Date, Image) VALUES (@UserId, @Title, @Description, @Price, @Location, @Date, @Image); SELECT SCOPE_IDENTITY()", conn);
        cmd.Parameters.AddWithValue("@UserId", listing.userId);
        cmd.Parameters.AddWithValue("@Title", listing.title);
        cmd.Parameters.AddWithValue("@Description", listing.description);
        cmd.Parameters.AddWithValue("@Price", listing.price);
        cmd.Parameters.AddWithValue("@Image", listing.imageId);
        cmd.Parameters.AddWithValue("@Location", listing.location);
        cmd.Parameters.AddWithValue("@Date", listing.date);
        int uid = Convert.ToInt32(cmd.ExecuteScalar());
        conn.Close();
        listing.ListingId = uid;

        return listing;
    }
Пример #16
0
        public void SetListing(Listing listing)
        {
            _listing = listing;
            CommentsListView.ItemsSource = null;
            CurrentListingProgressBar.Visibility = Visibility.Visible;

            UserHandleButton.Content = listing?.Handle;
            ListingTitleLabel.Text = listing?.Title;
            ListingAskingPrice.Content = listing?.Price;
            ListingConditionLabel.Content = listing?.Condition;
            ListingContentTextBlock.Text = listing?.Content;
            ListingTimePostedLabel.Content = HumanizeDateString(listing?.CreateDate.ToString(CultureInfo.InvariantCulture));
            NewCommentTextBox.Text = string.Empty;

            ScrollViewerContainer.ScrollToHome();

            SetCurrentListingImage();
            GetComments();
        }
Пример #17
0
 private async Task<Listing<Subreddit>> GetSubredditListAsync(string resourcePath)
 {
     Listing<Subreddit> _list = new Listing<Subreddit>(resourcePath, _reqServ);
     await _list.Refresh();
     return _list;
 }
Пример #18
0
	/// <summary>
	/// Raises the select my listing event.
	/// </summary>
	/// <param name='listing'>
	/// Listing.
	/// </param>
	protected void OnSelectMyListing(Listing listing)
	{
		m_isNotificationBrowserExpanded = false;
	}
Пример #19
0
 public FatFileStream(Listing.FatFile aFile):base(aFile, aFile.FileSystem, aFile.FirstClusterNum)
 {
 }
Пример #20
0
    public bool updateListing(String id, Listing listing)
    {
        // update listing in database

        return ListingDataService.updateListing(id, listing);
    }
Пример #21
0
 /// <summary>
 /// Get the flair text of a user.
 /// </summary>
 /// <param name="max">Maximum number of records to return.</param>
 public Listing <RedditUser> GetUserFlairList(int max = -1) => Listing <RedditUser> .Create(WebAgent, FlairListUrl, max, 1000);
Пример #22
0
        /// <summary>
        /// Gets the moderation log of the current subreddit filtered by moderator(s) who performed the action
        /// </summary>
        /// <param name="mods">String array of mods to filter by</param>
        /// <param name="max">Maximum number of records to return.</param>
        public Listing <ModAction> GetModerationLog(IEnumerable <string> mods, int max = -1)
        {
            var url = $"{ModLogUrl}?mod={string.Join(",", mods)}";

            return(Listing <ModAction> .Create(WebAgent, url, max, 500));
        }
 public ListingSuccessfulySavedMessage(Listing listing) : base(listing)
 {
 }
Пример #24
0
        public void FindBooksListedTest()
        {
            List <Book> initialFoundBooks = _dbc.FindBooksListed();

            //Arrange
            List <Book> booksListed = new List <Book>();

            Book    book1    = new Book("1111111111");
            Listing listing1 = listing;

            listing1.BookListed = book1;
            booksListed.Add(book1);

            Book    book2    = new Book("2222222222");
            Listing listing2 = listing;

            listing2.BookListed = book2;
            booksListed.Add(book2);

            Book    book3    = new Book("3333333333");
            Listing listing3 = listing;

            listing3.BookListed = book3;
            booksListed.Add(book3);

            Book    book4    = new Book("5555555555");
            Listing listing4 = listing;

            listing4.BookListed = book4;
            booksListed.Add(book4);

            Listing listing5 = listing;

            listing5.BookListed = book4;
            booksListed.Add(book4);

            Listing listing6 = listing;

            listing6.BookListed = book4;
            booksListed.Add(book4);

            //Act
            listing1 = _dbc.InsertListing(listing1);
            listing2 = _dbc.InsertListing(listing2);
            listing3 = _dbc.InsertListing(listing3);
            listing4 = _dbc.InsertListing(listing4);
            listing5 = _dbc.InsertListing(listing5);
            listing6 = _dbc.InsertListing(listing6);

            List <Book> newFoundBooks = _dbc.FindBooksListed();

            //Tear Down
            _dbc.DeleteListingByID(listing1.ListingID);
            _dbc.DeleteListingByID(listing2.ListingID);
            _dbc.DeleteListingByID(listing3.ListingID);
            _dbc.DeleteListingByID(listing4.ListingID);
            _dbc.DeleteListingByID(listing5.ListingID);
            _dbc.DeleteListingByID(listing6.ListingID);

            //Assert
            Assert.AreEqual(4, newFoundBooks.Count - initialFoundBooks.Count);
        }
Пример #25
0
 /// <summary>
 /// Return a <see cref="Listing{T}"/> of posts disliked by the logged in user.
 /// </summary>
 public Listing <Post> GetDislikedPosts(int max = -1) => Listing <Post> .Create(WebAgent, DislikedUrl, max, 100);
Пример #26
0
        public ActionResult Search()
        {
            ViewBag.Title = "Home Page";
            JArray items;
            string keyword    = "lamp";
            string postalcode = "48206";
            int    page;

            for (page = 1; page < 5; page++)
            {
                HttpWebRequest WR = WebRequest.CreateHttp($"http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords" +
                                                          $"&SERVICE-VERSION=1.0.0&GLOBAL-ID=EBAY-US&SECURITY-APPNAME=shaunitt-studenta-PRD-b7141958a-1d5c6f0c&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD=TRUE" +
                                                          $"&keywords={keyword}&buyerPostalCode={postalcode}&itemFilter.name=MaxDistance&itemFilter.value=40" +
                                                          $"&paginationInput.entriesPerPage=100&paginationInput.pageNumber={page}");

                HttpWebResponse Response;
                try
                {
                    Response = (HttpWebResponse)WR.GetResponse();
                }
                catch (WebException e)
                {
                    ViewBag.Error            = "Exception";
                    ViewBag.ErrorDescription = e.Message;
                    return(View());
                }

                //reads response
                StreamReader reader     = new StreamReader(Response.GetResponseStream());
                string       searchData = reader.ReadToEnd();
                //parses JSON
                JObject JsonData = JObject.Parse(searchData);

                //J array for items returned
                items = (JArray)JsonData["findItemsByKeywordsResponse"][0]["searchResult"][0]["item"];


                //instantiate new ebaylisting object
                Listing listing = new Listing();

                //instantiate new lamp entities database
                LampBaeEntities1 db = new LampBaeEntities1();

                List <Listing> LampDBList = new List <Listing>();

                LampDBList = (from p in db.Listings
                              where p.ID != 0
                              select p).ToList();

                for (int i = 0; i < items.Count; i++)
                {
                    if (LampDBList.Exists(x => x.EbayItemNumber != null && x.EbayItemNumber.ToString() == (string)items[i]["itemId"][0]))
                    {
                        //dupes detected
                    }
                    else
                    {
                        listing.ItemSearchURL  = (string)items[i]["viewItemURL"][0];
                        listing.Title          = (string)items[i]["title"][0];
                        listing.Image          = (string)items[i]["galleryURL"][0];
                        listing.PostalCode     = (string)items[i]["postalCode"][0];
                        listing.EbayItemNumber = (string)items[i]["itemId"][0];
                        listing.EndDate        = (DateTime)items[i]["listingInfo"][0]["endTime"][0];
                        listing.Price          = (decimal)items[i]["sellingStatus"][0]["currentPrice"][0]["__value__"];
                        new Listing()
                        {
                            EbayItemNumber = listing.EbayItemNumber, ItemSearchURL = listing.ItemSearchURL, Title = listing.Title, PostalCode = listing.PostalCode, Image = listing.Image
                        };
                        db.Listings.Add(listing);
                        db.SaveChanges();
                    }
                }
            }
            return(View());
        }
Пример #27
0
        public ActionResult Lamps(int?lampid)
        {
            ViewBag.Title = "Lamps";

            string userIP  = UtilityClass.GetIP();
            string userZip = UtilityClass.GetZip(userIP);

            //instantiate DB from model
            LampBaeEntities1 db = new LampBaeEntities1();

            //instantiate new list for lamp id's
            List <Listing> LampDBList = new List <Listing>();

            //populate list from Listing
            LampDBList = (from p in db.Listings
                          where p.ID != 0 ||
                          p.EndDate > DateTime.Now || //doesnt show lamps after its ended auction
                          p.ReportCount > 0    //doesn't show lamps that have been reported/flagged
                          select p).ToList();

            //instantiate new list for ratings
            List <ViewCount> ViewCountList = (from p in db.ViewCounts
                                              where p.ViewID != 0
                                              select p).ToList();

            //declaring our listing object
            Listing listing     = null;
            string  ItemZipCode = "";

            // if no lampid is provided, a random id will be generated and assigned to x
            if (lampid == null || lampid > LampDBList.Count || lampid < 0)
            {
                //instantiate new random object & create a new random int based on range of list count as max value
                Random r = new Random();
                lampid  = r.Next(1, LampDBList.Count());
                listing = (from p in db.Listings
                           where p.ID == lampid
                           select p).Single();
                ItemZipCode = listing.PostalCode;
            }

            else
            {
                //grabs a listing from list
                listing = (from p in db.Listings
                           where p.ID == lampid
                           select p).Single();
                ItemZipCode = listing.PostalCode;
            }

            //handling for ebay listings vs user listings (the image url structure is different)
            if (listing.EbayItemNumber == null)
            {
                ViewData["ItemTitle"]   = listing.Title;
                ViewData["Price"]       = listing.Price;
                ViewData["viewItemURL"] = ("/Home/LinkImage?lampid=" + listing.ID);
                ViewData["ImageURL"]    = Url.Content("~/Content/" + listing.Image);
            }
            else
            {
                ViewData["ItemTitle"]   = listing.Title;
                ViewData["Price"]       = listing.Price;
                ViewData["viewItemURL"] = listing.ItemSearchURL;
                ViewData["ImageURL"]    = listing.Image;
            }

            //test if view record exists already
            ViewCount existingViewCount = null;

            try
            {
                existingViewCount = (from m in db.ViewCounts
                                     where m.ItemID == lampid &&
                                     m.UserID == User.Identity.Name
                                     select m).Single();
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: '{0}'", e);
            }

            // if a view record already exists, simply increment
            if (existingViewCount != null)
            {
                existingViewCount.ViewCount1 = existingViewCount.ViewCount1 + 1;
                db.SaveChanges();
            }

            //if a view record doesn't already exist, create a new record and assign it a value of one
            else
            {
                ViewCount newviewcount = new ViewCount();
                newviewcount.UserID     = User.Identity.Name;
                newviewcount.ItemID     = (int)lampid;
                newviewcount.ViewCount1 = 1;
                newviewcount.ViewDate   = DateTime.Now;
                new ViewCount()
                {
                    UserID = newviewcount.UserID, ItemID = (int)lampid, ViewCount1 = 1, ViewDate = DateTime.Now
                };
                db.ViewCounts.Add(newviewcount);
                db.SaveChanges();
            }


            string distance = UtilityClass.GetZipCodeDistance(userZip, ItemZipCode);

            ViewBag.Distance          = distance;
            ViewData["CurrentLampID"] = listing.ID;
            ViewBag.UserZip           = userZip;
            ViewBag.CurrentUser       = User.Identity.Name;
            ViewBag.CurrentUserIP     = userIP;
            return(View());
        }
Пример #28
0
        //handles user and global rating.
        public ActionResult Rating(int lampid, int ratingvalue)
        {
            LampBaeEntities1 db = new LampBaeEntities1();

            //instantiate new list for lamp id's
            List <Listing> LampDBList = new List <Listing>();

            //grab listing based on lampid provided
            Listing listing = (from p in db.Listings
                               where p.ID == lampid
                               select p).Single();

            if (listing.Rating == null)
            {
                listing.Rating = 0;
                listing.Rating = listing.Rating + ratingvalue;
            }
            else
            {
                //global rating
                listing.Rating = listing.Rating + ratingvalue;
            }


            //user rating
            //instantiate new list for ratings
            List <Rating> RatingList = (from p in db.Ratings
                                        where p.RatingID != 0
                                        select p).ToList();

            Rating ratingrecord = new Rating();

            ratingrecord = null;

            // try to find a lamp with the lamp id/user id combo
            try
            {
                ratingrecord = (from m in db.Ratings
                                where m.ItemID == lampid &&
                                m.UserID == User.Identity.Name
                                select m).Single();
            }
            catch (Exception e)
            { }

            // if the record does not exist, then assign values, instantiate object and add the record.
            if (ratingrecord == null)
            {
                Rating rating = new Rating();

                rating.ItemID  = lampid;
                rating.UserID  = User.Identity.Name;
                rating.Rating1 = ratingvalue;
                new Rating {
                    ItemID = lampid, UserID = User.Identity.Name, Rating1 = ratingvalue
                };
                db.Ratings.Add(rating);
                db.SaveChanges();
            }

            // else, if a record exists, then increment or decrement the rating
            else
            {
                ratingrecord.Rating1 = ratingrecord.Rating1 + ratingvalue;
            }
            db.SaveChanges();
            return(RedirectToAction("Lamps"));
        }
Пример #29
0
        public ActionResult HotLamps()
        {
            LampBaeEntities1 db = new LampBaeEntities1();

            List <Listing> RatedLampList = new List <Listing>();

            RatedLampList = (from p in db.Listings
                             where p.Rating >= 1 &&
                             p.EndDate > DateTime.Now //doesnt show lamps after its ended auction
                             select p).ToList();

            //randomize the llist
            var rand = new Random();

            RatedLampList = RatedLampList.OrderBy(x => rand.Next()).ToList();

            ViewBag.RatedLampList = RatedLampList;

            //consider using try catch if ratedlamplist count returns 0
            if (RatedLampList.Count > 5)
            {
                ViewBag.RatedLampListCount = 5;
            }
            else if (RatedLampList.Count <= 5 && RatedLampList.Count != 0)
            {
                ViewBag.RatedLampListCount = RatedLampList.Count;
            }
            else
            {
                ViewBag.RatedLampListCount = "We don't have any popular lamps yet, check with us again soon!";
            }

            //instantiate list
            List <Rating> UserLikedLamps = new List <Rating>();

            //create list based on user ratings where rating is greater
            //than or equal to 1 and user ID from ratings matches logged in user name
            UserLikedLamps = (from u in db.Ratings
                              where u.Rating1 > 0 &&
                              u.UserID == User.Identity.Name
                              select u).ToList();
            //instantiate new list to add top liked lamps to later
            List <Listing> TopUserLikedLamps = new List <Listing>();

            //instantiate new listing object
            Listing listing = new Listing();

            //add top 5 rated lamps to top user like lamps
            if (UserLikedLamps.Count != 0)
            {
                if (UserLikedLamps.Count < 5)
                {
                    for (int i = 0; i < UserLikedLamps.Count; i++)
                    {
                        var LampId = UserLikedLamps[i].ItemID;
                        listing = db.Listings.Find(LampId);
                        TopUserLikedLamps.Add(listing);
                    }
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        var LampId = UserLikedLamps[i].ItemID;
                        listing = db.Listings.Find(LampId);
                        TopUserLikedLamps.Add(listing);
                    }
                }
            }
            else
            {
            }
            TopUserLikedLamps = TopUserLikedLamps.OrderBy(x => rand.Next()).ToList();
            //place list results in viewbag
            ViewBag.TU = TopUserLikedLamps;


            List <Friend> UserFriendPairs = new List <Friend>();

            UserFriendPairs = (from u in db.Friends
                               where u.UserID1 == User.Identity.Name ||
                               u.UserID2 == User.Identity.Name
                               select u).ToList();

            List <string> FriendsList = new List <string>();

            foreach (Friend friends in UserFriendPairs)
            {
                if (friends.UserID1 != User.Identity.Name.ToString() &&

                    !FriendsList.Contains(friends.UserID1))

                {
                    FriendsList.Add(friends.UserID1);
                }

                else if (
                    friends.UserID2 != User.Identity.Name.ToString() &&
                    !FriendsList.Contains(friends.UserID2))
                {
                    FriendsList.Add(friends.UserID2);
                }
            }

            List <Rating> FriendsLikedLamps = new List <Rating>();

            foreach (string friend in FriendsList)
            {
                FriendsLikedLamps = (from u in db.Ratings
                                     where u.Rating1 > 0 &&
                                     u.UserID == friend
                                     select u).ToList();
            }



            //instantiate new list to add top liked lamps to later
            List <Listing> FriendsLikedLampListings = new List <Listing>();

            //add 5 rated lamps to FriendsLikedLampListings
            if (FriendsLikedLamps.Count != 0)
            {
                if (FriendsLikedLamps.Count < 5)
                {
                    for (int i = 0; i < FriendsLikedLamps.Count; i++)
                    {
                        var LampId = FriendsLikedLamps[i].ItemID;
                        listing = db.Listings.Find(LampId);
                        FriendsLikedLampListings.Add(listing);
                    }
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        var LampId = FriendsLikedLamps[i].ItemID;
                        listing = db.Listings.Find(LampId);
                        FriendsLikedLampListings.Add(listing);
                    }
                }
            }
            else
            {
            }
            FriendsLikedLampListings = FriendsLikedLampListings.OrderBy(x => rand.Next()).ToList();
            ViewBag.FriendsLamps     = FriendsLikedLampListings;
            return(View());
        }
Пример #30
0
 void m_Click(object sender, RoutedEventArgs e)
 {
     Listing item = (sender as MenuItem).DataContext as Listing;
 }
        public async Task <string> UpdateAsync([FromBody] Listing listing)
        {
            var response = await _listingService.UpdateListingAsync(Map.WebToDB(listing));

            return(response);
        }
Пример #32
0
        /// <summary>
        /// Gets the moderation log of the current subreddit filtered by the action taken
        /// </summary>
        /// <param name="action">ModActionType of action performed</param>
        /// <param name="max">Maximum number of records to return.</param>
        public Listing <ModAction> GetModerationLog(ModActionType action, int max = -1)
        {
            var url = $"{ModLogUrl}?type={action.ToString("g").ToLower()}";

            return(Listing <ModAction> .Create(WebAgent, url, max, 500));
        }
Пример #33
0
        /// <summary>
        /// Gets the moderation log of the current subreddit filtered by the action taken and moderator(s) who performed the action
        /// </summary>
        /// <param name="action">ModActionType of action performed.</param>
        /// <param name="mods">String array of mods to filter by.</param>
        /// <param name="max">Maximum number of records to return.</param>
        /// <returns></returns>
        public Listing <ModAction> GetModerationLog(ModActionType action, IEnumerable <string> mods, int max = -1)
        {
            var url = $"{ModLogUrl}?type={action}";

            return(Listing <ModAction> .Create(WebAgent, url, max, 500));
        }
Пример #34
0
        private void SetListing(Listing listing)
        {
            if(_listing != null)
                _listing.Unload(SelectedCore);

            _listing = listing;
            listingBox.SelectionBackColor = Color.FromArgb(34, 26, 55);
            listingBox.Lines = listing.Lines.ToArray();
            _listing.Parse(listingBox.Lines);
            _listing.Compile(SelectedCore);
            UpdateView(false);
        }
Пример #35
0
 /// <summary>
 /// Return the users overview.
 /// </summary>
 public Listing <VotableThing> GetOverview(int max = -1) => Listing <VotableThing> .Create(WebAgent, OverviewUrl, max, 100);
Пример #36
0
 public Viewing()
 {
     ViewingHost = new OperatingUser();
     Listing     = new Listing();
     Customer    = new Customer();
 }
Пример #37
0
 /// <summary>
 /// Gets the moderation log of the current subreddit
 /// </summary>
 public Listing <ModAction> GetModerationLog(int max = -1) => Listing <ModAction> .Create(WebAgent, ModLogUrl, max, 500);
Пример #38
0
 /// <summary>
 /// Return a <see cref="Listing{T}"/> of posts made by the user.
 /// </summary>
 public Listing <Post> GetPosts(int max = -1) => Listing <Post> .Create(WebAgent, LinksUrl, max, 100);
Пример #39
0
    public Listing postListing(Listing listing)
    {
        // post listing to database

        return ListingDataService.addListing(listing);
    }
Пример #40
0
 public static void SendTo( Mobile m, Listing listing )
 {
     new ListGump( m, listing );
 }
Пример #41
0
        private void OnListingChanged(Listing sender)
        {
            if(_started)
                return;

            int index = _deck.IndexOf(sender);
            foreach (Core core in _grid.ListOfEntries.Where(e => e.ListingID == index).Select(e => e.Core))
            {
                core.ClearMemory();
                sender.Compile(core);
                Draw(core);
            }
        }
Пример #42
0
        //The parameters are the required for creating the listing
        //The shipping template must be created in a different process
        //as they may not be set up on an account
        //STATE MUST BE DRAFT
        public Listing CreateListing(RestClient RestClient, Listing Listing)
        {
            string strmaterials = string.Empty;

            foreach (var m in Listing.materials)
            {
                strmaterials += m.Replace("\"", "").Replace(".", "").Replace("%", "");
                if (Listing.materials.Last() != m)
                {
                    strmaterials += ",";
                }
            }
            string strtags = string.Empty;

            foreach (var t in Listing.tags)
            {
                strtags += t;
                if (Listing.tags.Last() != t)
                {
                    strtags += ",";
                }
            }

            Console.WriteLine("Creating Listing {0}", Listing.title);
            RestRequest request = new RestRequest();

            request.Method = Method.POST;
            request.AddParameter("quantity", Listing.quantity);
            request.AddParameter("title", Listing.title);
            request.AddParameter("description", Listing.description);
            request.AddParameter("price", Listing.price);
            request.AddParameter("shipping_template_id", Listing.shipping_template_id);
            request.AddParameter("state", Listing.state);
            request.AddParameter("is_supply", Listing.is_supply);
            request.AddParameter("who_made", Listing.who_made);
            request.AddParameter("when_made", Listing.when_made);
            request.AddParameter("materials", strmaterials);
            request.AddParameter("tags", strtags);
            request.AddParameter("category_id", Listing.category_id);
            request.AddParameter("taxonomy_id", Listing.taxonomy_id);
            request.Resource = "/listings";

            try
            {
                IRestResponse response = RestClient.Execute(request);
                if (response.StatusCode == System.Net.HttpStatusCode.Created)
                {
                    JObject o       = JObject.Parse(response.Content);
                    Listing listing = JsonConvert.DeserializeObject <Listing>(o["results"][0].ToString());
                    Thread.Sleep(2000);
                    Console.WriteLine("listing created...");
                    return(listing);
                }
                else
                {
                    Console.WriteLine("Listing was unable to be created: {0}", response.StatusDescription);
                    Thread.Sleep(2000);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An Error has happened in the CreateListing Method : {0}", ex.ToString());
                return(null);
            }
        }
Пример #43
0
 /// <summary>
 /// Get a <see cref="Listing{T}"/> of banned users.
 /// </summary>
 public Listing <BannedUser> GetBannedUsers(int max = -1) => Listing <BannedUser> .Create(WebAgent, BannedUsersUrl, max, 100);
Пример #44
0
        public void ImportListing(RestClient RestClient)
        {
            var dictListings = ImportHelpers.ImportTabDelimitedFile(@"C:\Internal\Etsy\listingimport.txt");
            var gclient      = InternalClientService.GetInternalClientByID(dictListings.Where(x => x.Key == 2).First().Value[0].ToString());
            //GETTING SHIPPING TEMPLATE
            string shiptempId = ShippingTemplateService.GetShippingTemplateId(RestClient, gclient.EtsyUserName);
            //string status = ShippingTemplateService.CreateShippingTemplate(RestClient, "Test Shipping Template", countries.Where(x => x.Value == "United States").FirstOrDefault().Key.ToString(), "2.00", "1.00");
            var countries = CountryService.GetCountryMapping(RestClient);

            foreach (var row in dictListings.Skip(1))
            {
                if (row.Key != 1)
                {
                    Console.WriteLine("CREATING A DRAFT LISTING");
                    var     obj         = row.Value;
                    Listing testListing = new Listing
                    {
                        title                = obj[1].ToString(),
                        description          = obj[2].ToString(),
                        price                = obj[3].ToString(),
                        quantity             = obj[7].ToString(),
                        shipping_template_id = shiptempId,
                        state                = "draft",
                        is_supply            = "false",
                        who_made             = "i_did",
                        when_made            = "made_to_order",
                    };
                    //var listing = CreateListing(RestClient, testListing);

                    Console.WriteLine("CREATING A LISTING IMAGE");
                    string filepath = string.Format(@"C:\Internal\EtsyProductImages\{0}", obj[4].ToString());
                    //CreateListingItemImage(RestClient, listing, obj[4].ToString(), filepath);

                    Console.WriteLine("CREATE LISTING VARIATIONS");
                    List <ListingVariation> variations = new List <ListingVariation>();
                    ListingVariation        variation;

                    List <string> sizes = new List <string> {
                        "S", "M", "L", "XL", "XXL"
                    };
                    string style = obj[6].ToString();
                    foreach (var size in sizes)
                    {
                        variation             = new ListingVariation();
                        variation.property_id = "513";
                        //variation.is_available = "TRUE";
                        variation.value = string.Format("{0}-{1}", size, style);
                        variations.Add(variation);
                    }

                    List <string> designs = obj[5].ToString().Split(';').ToList();
                    foreach (var design in designs)
                    {
                        string[] designcolor = design.Split(':');
                        variation             = new ListingVariation();
                        variation.property_id = "200";
                        variation.value       = string.Format("{0}-{1}", designcolor[0], designcolor[1]);
                        variations.Add(variation);
                    }
                    string output = JsonConvert.SerializeObject(variations.ToArray());
                    //UpdateListingVariations(RestClient, listing, output);
                    Console.WriteLine("Listing Created");
                    Thread.Sleep(1000);
                }
            }
        }
Пример #45
0
 public static IEnumerable<OenologueV1> Lister(MyDB BD, Listing Modalite)
 {
     string Requete = "SELECT * FROM oenologue";
     if (Modalite == Listing.UniquementNonReferences) Requete += " WHERE id NOT IN (SELECT DISTINCT ref_oenologue FROM avis)";
     return BD.Read(Requete).Select<MyDB.IRecord, OenologueV1>(Enregistrement => Creer(Enregistrement));
 }
Пример #46
0
 /// <summary>
 /// Get a <see cref="Listing{T}"/> of contributors.
 /// </summary>
 public Listing <Contributor> GetContributors(int max = -1) => Listing <Contributor> .Create(WebAgent, ContributorsUrl, max, 100);
Пример #47
0
        void RenderListing(Listing listing)
        {
            Push("listing");

            foreach (ListingItem item in listing.Items)
            {
                Push("list-item");

                RenderBlockSequence(item);

                Pop();
            }

            Pop();
        }
Пример #48
0
        public async Task <ActionResult> ListingUpdate(Listing listing, FormCollection form, IEnumerable <HttpPostedFileBase> files)
        {
            if (CacheHelper.Categories.Count == 0)
            {
                TempData[TempDataKeys.UserMessageAlertState] = "bg-danger";
                TempData[TempDataKeys.UserMessage]           = "[[[There are not categories available yet.]]]";

                return(RedirectToAction("Listing", new { id = listing.ID }));
            }

            var userIdCurrent = User.Identity.GetUserId();

            // Register account if not login
            if (!User.Identity.IsAuthenticated)
            {
                var accountController = BeYourMarket.Core.ContainerManager.GetConfiguredContainer().Resolve <AccountController>();

                var modelRegister = new RegisterViewModel()
                {
                    Email           = listing.ContactEmail,
                    Password        = form["Password"],
                    ConfirmPassword = form["ConfirmPassword"],
                };

                // Parse first and last name
                var names = listing.ContactName.Split(' ');
                if (names.Length == 1)
                {
                    modelRegister.FirstName = names[0];
                }
                else if (names.Length == 2)
                {
                    modelRegister.FirstName = names[0];
                    modelRegister.LastName  = names[1];
                }
                else if (names.Length > 2)
                {
                    modelRegister.FirstName = names[0];
                    modelRegister.LastName  = listing.ContactName.Substring(listing.ContactName.IndexOf(" ") + 1);
                }

                // Register account
                var resultRegister = await accountController.RegisterAccount(modelRegister);

                // Add errors
                AddErrors(resultRegister);

                // Show errors if not succeed
                if (!resultRegister.Succeeded)
                {
                    var model = new ListingUpdateModel()
                    {
                        ListingItem = listing
                    };
                    // Populate model with listing
                    await PopulateListingUpdateModel(listing, model);

                    return(View("ListingUpdate", model));
                }

                // update current user id
                var user = await UserManager.FindByNameAsync(listing.ContactEmail);

                userIdCurrent = user.Id;
            }

            bool updateCount = false;

            int nextPictureOrderId = 0;

            // Set default listing type ID
            if (listing.ListingTypeID == 0)
            {
                var listingTypes = CacheHelper.ListingTypes.Where(x => x.CategoryListingTypes.Any(y => y.CategoryID == listing.CategoryID));

                if (listingTypes == null)
                {
                    TempData[TempDataKeys.UserMessageAlertState] = "bg-danger";
                    TempData[TempDataKeys.UserMessage]           = "[[[There are not listing types available yet.]]]";

                    return(RedirectToAction("Listing", new { id = listing.ID }));
                }

                listing.ListingTypeID = listingTypes.FirstOrDefault().ID;
            }

            if (listing.ID == 0)
            {
                listing.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added;
                listing.IP          = Request.GetVisitorIP();
                listing.Expiration  = DateTime.MaxValue.AddDays(-1);
                listing.UserID      = userIdCurrent;
                listing.Enabled     = true;
                listing.Currency    = CacheHelper.Settings.Currency;

                updateCount = true;
                _listingService.Insert(listing);
            }
            else
            {
                if (await NotMeListing(listing.ID))
                {
                    return(new HttpUnauthorizedResult());
                }

                var listingExisting = await _listingService.FindAsync(listing.ID);

                listingExisting.Title       = listing.Title;
                listingExisting.Description = listing.Description;
                listingExisting.Number      = listing.Number;
                listingExisting.Active      = listing.Active;
                listingExisting.Price       = listing.Price;

                listingExisting.ContactEmail = listing.ContactEmail;
                listingExisting.ContactName  = listing.ContactName;
                listingExisting.ContactPhone = listing.ContactPhone;

                listingExisting.Latitude  = listing.Latitude;
                listingExisting.Longitude = listing.Longitude;
                listingExisting.Location  = listing.Location;

                listingExisting.ShowPhone = listing.ShowPhone;
                listingExisting.ShowEmail = listing.ShowEmail;

                listingExisting.CategoryID    = listing.CategoryID;
                listingExisting.ListingTypeID = listing.ListingTypeID;

                listingExisting.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Modified;

                _listingService.Update(listingExisting);
            }

            // Delete existing fields on item
            var customFieldItemQuery = await _customFieldListingService.Query(x => x.ListingID == listing.ID).SelectAsync();

            var customFieldIds = customFieldItemQuery.Select(x => x.ID).ToList();

            foreach (var customFieldId in customFieldIds)
            {
                await _customFieldListingService.DeleteAsync(customFieldId);
            }

            // Get custom fields
            var customFieldCategoryQuery = await _customFieldCategoryService.Query(x => x.CategoryID == listing.CategoryID).Include(x => x.MetaField.ListingMetas).SelectAsync();

            var customFieldCategories = customFieldCategoryQuery.ToList();

            foreach (var metaCategory in customFieldCategories)
            {
                var field       = metaCategory.MetaField;
                var controlType = (BeYourMarket.Model.Enum.Enum_MetaFieldControlType)field.ControlTypeID;

                string controlId = string.Format("customfield_{0}_{1}_{2}", metaCategory.ID, metaCategory.CategoryID, metaCategory.FieldID);

                var formValue = form[controlId];

                if (string.IsNullOrEmpty(formValue))
                {
                    continue;
                }

                formValue = formValue.ToString();

                var itemMeta = new ListingMeta()
                {
                    ListingID   = listing.ID,
                    Value       = formValue,
                    FieldID     = field.ID,
                    ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added
                };

                _customFieldListingService.Insert(itemMeta);
            }

            //.......
            //.......
            //.......
            //after publish product, must pay 100 coins...............................................
            //update coins of user
            string user_id      = User.Identity.GetUserId();
            var    userExisting = await UserManager.FindByIdAsync(user_id);

            userExisting.Coins = userExisting.Coins - 100;
            await UserManager.UpdateAsync(userExisting);

            OrderBuyCoin orderbuycoin = new OrderBuyCoin();

            orderbuycoin.Date        = DateTime.Now;
            orderbuycoin.Price       = 0;
            orderbuycoin.Coins       = 100;
            orderbuycoin.UserBuyCoin = user_id;
            orderbuycoin.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added;
            _orderBuyCoinService.Insert(orderbuycoin);


            await _unitOfWorkAsync.SaveChangesAsync();

            if (Request.Files.Count > 0)
            {
                var itemPictureQuery = _listingPictureservice.Queryable().Where(x => x.ListingID == listing.ID);
                if (itemPictureQuery.Count() > 0)
                {
                    nextPictureOrderId = itemPictureQuery.Max(x => x.Ordering);
                }
            }

            if (files != null && files.Count() > 0)
            {
                foreach (HttpPostedFileBase file in files)
                {
                    if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                    {
                        // Picture picture and get id
                        var picture = new Picture();
                        picture.MimeType = "image/jpeg";
                        _pictureService.Insert(picture);
                        await _unitOfWorkAsync.SaveChangesAsync();

                        // Format is automatically detected though can be changed.
                        ISupportedImageFormat format = new JpegFormat {
                            Quality = 90
                        };
                        Size size = new Size(500, 0);

                        //https://naimhamadi.wordpress.com/2014/06/25/processing-images-in-c-easily-using-imageprocessor/
                        // Initialize the ImageFactory using the overload to preserve EXIF metadata.
                        using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
                        {
                            var path = Path.Combine(Server.MapPath("~/images/listing"), string.Format("{0}.{1}", picture.ID.ToString("00000000"), "jpg"));

                            // Load, resize, set the format and quality and save an image.
                            imageFactory.Load(file.InputStream)
                            .Resize(size)
                            .Format(format)
                            .Save(path);
                        }

                        var itemPicture = new ListingPicture();
                        itemPicture.ListingID = listing.ID;
                        itemPicture.PictureID = picture.ID;
                        itemPicture.Ordering  = nextPictureOrderId;

                        _listingPictureservice.Insert(itemPicture);

                        nextPictureOrderId++;
                    }
                }
            }

            await _unitOfWorkAsync.SaveChangesAsync();

            // Update statistics count
            if (updateCount)
            {
                _sqlDbService.UpdateCategoryItemCount(listing.CategoryID);
                _dataCacheService.RemoveCachedItem(CacheKeys.Statistics);
            }

            TempData[TempDataKeys.UserMessage] = "[[[Listing is updated!]]]";
            return(RedirectToAction("Listing", new { id = listing.ID }));
        }
Пример #49
0
 /// <summary>
 /// Return a list of subscribed subreddits for the logged in user.
 /// </summary>
 public Listing <Subreddit> GetSubscribedSubreddits(int max = -1) => Listing <Subreddit> .Create(WebAgent, SubscribedSubredditsUrl, max, 100);
        public async Task <string> SaveNewAsync([FromBody] Listing newListing)
        {
            var response = await _listingService.SaveNewListingAsync(Map.WebToDB(newListing));

            return(response);
        }
Пример #51
0
        private void List( object obj )
        {
            if ( !(obj is int) )
                return;

            if ( (int)obj == -1 )
                obj = (int)c_Listing;

            if ( (Listing)obj == Listing.Staff
            && !ChatInfo.ShowStaff
            && Owner.AccessLevel == AccessLevel.Player )
                NewGump();
            else if ( (Listing)obj == Listing.Faction
            && !ChatInfo.AllowFaction )
                NewGump();
            else
            {
                c_Listing = (Listing)obj;
                NewGump();
            }
        }
Пример #52
0
 /// <summary>
 /// Listing of items a moderator or the spam filter has removed. These posts are only available to a
 /// moderator with posts permissions.
 /// </summary>
 /// <param name="max">Maximum number of records to return.  -1 for unlimited.</param>
 /// <returns></returns>
 public Listing <VotableThing> GetRemoved(int max = -1) => Listing <VotableThing> .Create(WebAgent, SpamUrl, max, 100);
Пример #53
0
 public async Task CacheIt(Listing listing)
 {
     if (listing != null && listing.Data.Children != null && listing.Data.Children.Count > 0)
         await _offlineService.StoreOrderedThings("links:" + _subreddit, listing.Data.Children);
 }
Пример #54
0
        public async Task <ActionResult> ListingUpdate(int?id)
        {
            if (CacheHelper.Categories.Count == 0)
            {
                TempData[TempDataKeys.UserMessageAlertState] = "bg-danger";
                TempData[TempDataKeys.UserMessage]           = "[[[There are not categories available yet.]]]";
            }

            Listing listing;

            var userId = User.Identity.GetUserId();
            var user   = await UserManager.FindByIdAsync(userId);

            var model = new ListingUpdateModel()
            {
                Categories = CacheHelper.Categories
            };

            if (id.HasValue)
            {
                // return unauthorized if not authenticated
                if (!User.Identity.IsAuthenticated)
                {
                    return(new HttpUnauthorizedResult());
                }

                if (await NotMeListing(id.Value))
                {
                    return(new HttpUnauthorizedResult());
                }

                listing = await _listingService.FindAsync(id);

                if (listing == null)
                {
                    return(new HttpNotFoundResult());
                }

                // Pictures
                var pictures = await _listingPictureservice.Query(x => x.ListingID == id).SelectAsync();

                var picturesModel = pictures.Select(x =>
                                                    new PictureModel()
                {
                    ID        = x.PictureID,
                    Url       = ImageHelper.GetListingImagePath(x.PictureID),
                    ListingID = x.ListingID,
                    Ordering  = x.Ordering
                }).OrderBy(x => x.Ordering).ToList();

                model.Pictures = picturesModel;
            }
            else
            {
                listing = new Listing()
                {
                    CategoryID  = CacheHelper.Categories.Any() ? CacheHelper.Categories.FirstOrDefault().ID : 0,
                    Created     = DateTime.Now.Date,
                    LastUpdated = DateTime.Now.Date,
                    Expiration  = DateTime.MaxValue,
                    Enabled     = true,
                    Active      = true,
                };

                if (User.Identity.IsAuthenticated)
                {
                    listing.ContactEmail = user.Email;
                    listing.ContactName  = string.Format("{0} {1}", user.FirstName, user.LastName);
                    listing.ContactPhone = user.PhoneNumber;
                }
            }

            // Populate model with listing
            await PopulateListingUpdateModel(listing, model);

            return(View("~/Views/Listing/ListingUpdate.cshtml", model));
        }
Пример #55
0
 /// <summary>
 /// Return a <see cref="Listing{T}"/> of comments made by the user.
 /// </summary>
 public Listing <Comment> GetComments(int max = -1) => Listing <Comment> .Create(WebAgent, CommentsUrl, max, 100);
Пример #56
0
 /// <summary>
 /// Listing of items that have been edited. These posts are only available to a moderator with posts
 /// permissions.
 /// </summary>
 /// <param name="max">Maximum number of records to return.  -1 for unlimited.</param>
 /// <returns></returns>
 public Listing <VotableThing> GetEdited(int max = -1) => Listing <VotableThing> .Create(WebAgent, EditedUrl, max, 100);
Пример #57
0
    /* search items will have larger divisions */
    private string createSearchItemDiv(Listing listing)
    {
        string objectHTML = "";

        objectHTML += "<div class=\"search_item_div\" onclick=\"javascript:preview(" + listing.ListingId + ", '1')\" runat=\"server\">";

        /* object image */
        objectHTML += "<table><tr><td class=\"search_item_div_cell1\"><div class=\"search_item_img\"><img width=\"40px\" height=\"40px\" src=\"../Helpers/GetThumbnail.ashx?ID=" + listing.imageId + "\"></img></div></td>";

        /* vertical rule in div */
        objectHTML += "<td class=\"search_item_div_cell2\" style=\"border-left: 1px solid #999; width=0px;\"></td>";

        /* object title */
        objectHTML += "<td class=\"search_item_div_cell3\" style=\"width: 100%\"><td class=\"search_item_div_cell3\"><div class=\"search_item_title\">" + listing.title + "</div>";

        /* object description */
        objectHTML += "<div class=\"search_item_description\">" + listing.description + "</div>";

        /* object price */
        objectHTML += "<div class=\"search_item_price\">" + listing.price + "$ </div></td></tr></table>";

        objectHTML += "</div></br>";

        return objectHTML;
    }
Пример #58
0
 /// <summary>
 /// List of items in the mod queue
 /// </summary>
 /// <param name="max">Maximum number of records to return.  -1 for unlimited.</param>
 public Listing <VotableThing> GetModQueue(int max = -1) => Listing <VotableThing> .Create(WebAgent, ModqueueUrl, max, 100);
Пример #59
0
 public ValidatedListing(string sessionId, Listing listing)
 {
     this.SessionID = sessionId;
     this.Listing = listing;
 }
Пример #60
0
 /// <summary>
 /// Links a moderator hasn't checked
 /// </summary>
 /// <param name="max">Maximum number of records to return.  -1 for unlimited.</param>
 public Listing <Post> GetUnmoderatedLinks(int max = -1) => Listing <Post> .Create(WebAgent, UnmoderatedUrl, max, 100);