public async Task <string> SaveNewListingAsync(DatabaseModels.Listing newListing)
        {
            _context.Listings.Add(newListing);
            _context.Items.Add(newListing.Item);
            foreach (DatabaseModels.ItemAttribute ia in newListing.Item.attributes)
            {
                _context.ItemAttributes.Add(ia);
            }
            foreach (DatabaseModels.ItemMeasurement im in newListing.Item.measurements)
            {
                _context.ItemMeasurements.Add(im);
            }
            await _context.SaveChangesAsync();

            return("success");
        }
 public async Task <string> UpdateListingAsync(DatabaseModels.Listing listing)
 {
     _context.Entry(listing).State      = EntityState.Modified;
     _context.Entry(listing.Item).State = EntityState.Modified;
     foreach (DatabaseModels.ItemAttribute ia in listing.Item.attributes)
     {
         _context.Entry(ia).State = EntityState.Modified;
     }
     foreach (DatabaseModels.ItemMeasurement im in listing.Item.measurements)
     {
         _context.Entry(im).State = EntityState.Modified;
     }
     try
     {
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         return("error");
     }
     return("success");
 }
Пример #3
0
 public async Task <string> UpdateListingAsync(DatabaseModels.Listing listing)
 {
     return(await _listingRepository.UpdateListingAsync(listing));
 }
Пример #4
0
 public async Task <string> SaveNewListingAsync(DatabaseModels.Listing newListing)
 {
     return(await _listingRepository.SaveNewListingAsync(newListing));
 }