Exemplo n.º 1
0
 public void PublishListing(Listing listing)
 {
     using (var domain = new CraigslistDomain())
     {
         domain.Listings.Add(listing);
         domain.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public void DeactivateListingByRemovalId(string removalId)
        {
            using (var domain = new CraigslistDomain())
            {
                var listingToDeactivate = domain
                    .Listings
                    .FirstOrDefault(listing => listing.RemovalGuid == removalId);

                if (listingToDeactivate != null)
                {
                    listingToDeactivate.IsActive = false;
                    listingToDeactivate.Updated = DateTime.Now;
                    domain.SaveChanges();
                }
            }
        }
Exemplo n.º 3
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();
            }
        }