Example #1
0
        public async Task <Models.ConData.ImageType> DeleteImageType(int?imageTypeId)
        {
            var item = context.ImageTypes
                       .Where(i => i.ImageTypeID == imageTypeId)
                       .FirstOrDefault();

            if (item == null)
            {
                throw new Exception("Item no longer available");
            }

            OnImageTypeDeleted(item);

            context.ImageTypes.Remove(item);

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                context.Entry(item).State = EntityState.Unchanged;
                throw ex;
            }

            return(item);
        }
        public async Task <Models.ConData.Market> DeleteMarket(int?marketListId)
        {
            var item = context.Markets
                       .Where(i => i.MarketListID == marketListId)
                       .FirstOrDefault();

            if (item == null)
            {
                throw new Exception("Item no longer available");
            }

            OnMarketDeleted(item);

            context.Markets.Remove(item);

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                context.Entry(item).State = EntityState.Unchanged;
                throw ex;
            }

            return(item);
        }
Example #3
0
        public async Task <Models.ConData.ClubDetail> DeleteClubDetail(int?teamId)
        {
            var item = context.ClubDetails
                       .Where(i => i.TeamID == teamId)
                       .Include(i => i.Players)
                       .Include(i => i.PlayerTransfers)
                       .Include(i => i.PlayerTransfers1)
                       .Include(i => i.Users)
                       .FirstOrDefault();

            if (item == null)
            {
                throw new Exception("Item no longer available");
            }

            OnClubDetailDeleted(item);

            context.ClubDetails.Remove(item);

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                context.Entry(item).State = EntityState.Unchanged;
                throw ex;
            }

            return(item);
        }
        public async Task <Models.ConData.Country> DeleteCountry(int?countryId)
        {
            var item = context.Countries
                       .Where(i => i.CountryID == countryId)
                       .Include(i => i.MyFriends)
                       .FirstOrDefault();

            if (item == null)
            {
                throw new Exception("Item no longer available");
            }

            OnCountryDeleted(item);

            context.Countries.Remove(item);

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                context.Entry(item).State = EntityState.Unchanged;
                throw ex;
            }

            return(item);
        }