Exemplo n.º 1
0
        public async Task UpdateAsync(GeographicArea geographicAreaToSave)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                db.Entry(geographicAreaToSave).State = EntityState.Modified;
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "GeographicAreaRepository.UpdateAsync", timespan.Elapsed, "geographicAreaToSave={0}", geographicAreaToSave);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in GeographicAreaRepository.UpdateAsync(geographicAreaToSave={0})", geographicAreaToSave);
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task CreateAsync(GeographicArea geographicAreaToAdd)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                db.GeographicAreas.Add(geographicAreaToAdd);
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "GeographicAreaRepository.CreateAsync", timespan.Elapsed, "geographicAreaToAdd={0}", geographicAreaToAdd);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in GeographicAreaRepository.CreateAsync(geographicAreaToAdd={0})", geographicAreaToAdd);
                throw;
            }
        }
Exemplo n.º 3
0
        public async Task DeleteAsync(int geographicAreaID)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                GeographicArea geographicArea = await db.GeographicAreas.FindAsync(geographicAreaID);

                db.GeographicAreas.Remove(geographicArea);
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "GeographicAreaRepository.DeleteAsync", timespan.Elapsed, "geographicAreaID={0}", geographicAreaID);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in GeographicAreaRepository.DeleteAsync(geographicAreaID={0})", geographicAreaID);
                throw;
            }
        }
Exemplo n.º 4
0
        public List <TransportType> FindTransportTypeByGeographicArea(int geographicAreaID)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                GeographicArea geographicArea = db.GeographicAreas.Where(p => p.GeographicAreaID == geographicAreaID).Single();
                var            result         = geographicArea.GeographicAreaTransportTypes.Select(s => s.TransportType).ToList();


                timespan.Stop();
                log.TraceApi("SQL Database", "GeographicAreaTransportTypeRepository.FindTransportTypeByGeographicArea", timespan.Elapsed, "geographicAreaID={0}", geographicAreaID);

                return(result);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in GeographicAreaTransportTypeRepository.FindTransportTypeByGeographicArea(geographicAreaID={0})", geographicAreaID);
                throw;
            }
        }