Esempio n. 1
0
 public void PublishListing(Listing listing)
 {
     using (var domain = new CraigslistDomain())
     {
         domain.Listings.Add(listing);
         domain.SaveChanges();
     }
 }
Esempio n. 2
0
        public void UpdateListing(Listing listing)
        {
            using (var domain = new CraigslistDomain())
            {
                var currentLising = domain.Listings.FirstOrDefault(l => l.Id == listing.Id);
                currentLising.Header = listing.Header;
                currentLising.Body = listing.Body;
                currentLising.CategoryId = listing.CategoryId;
                currentLising.FeaturedImageData = listing.FeaturedImageData;
                currentLising.FeaturedImageMimeType = listing.FeaturedImageMimeType;
                currentLising.Price = listing.Price;

                currentLising.Contact.FirstName = listing.Contact.FirstName;
                currentLising.Contact.LastName = listing.Contact.LastName;
                currentLising.Contact.Phone = listing.Contact.Phone;
                currentLising.Contact.Email = listing.Contact.Email;
                domain.SaveChanges();
            }
        }
        public void PublishTest()
        {
            Contact contact = new Contact
            {
                FirstName = "Test_FName",
                LastName = "Test_LName",
                Phone = "9999999999",
                Email = "*****@*****.**",
                Id = 0,
                Updated = null
            };
            Listing listing = new Listing
            {
                Body = "Publist test body",
                Header = "PublishTest",
                Price = 300,
                CategoryId = 3,
                Category = null,
                ContactId = 0,
                RemovalGuid = Guid.NewGuid().ToString(),
                Contact = contact,
                IsActive = false,
                Id = 0,
                Updated = null
            };

            listingManager.PublishListing(listing);

            var added_listing = domain.Listings
                .Where(e => e.Body == listing.Body &&
                            e.Header == listing.Header &&
                            e.Price == listing.Price &&
                            e.CategoryId == listing.CategoryId &&
                            e.ContactId == listing.ContactId).Single();

            Assert.IsNotNull(added_listing);

            domain.Listings.Remove(added_listing);
        }