public async Task <Response> Delete(int idLocation)
        {
            Response response = new Response();

            try
            {
                using (SmartParkingContext context = new SmartParkingContext())
                {
                    context.Entry <LocationDTO>(new LocationDTO()
                    {
                        ID = idLocation
                    }).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                    int nLinhasAfetadas = await context.SaveChangesAsync();

                    if (nLinhasAfetadas == 1)
                    {
                        response.Success = true;
                        return(response);
                    }

                    response.Errors.Add("Exclusão não executada");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.Errors.Add("Erro no banco de dados contate o administrador");
                throw ex;
            }
        }
Esempio n. 2
0
        public async Task <Response> Insert(BrandDTO brand)
        {
            Response response = new Response();

            try
            {
                using (SmartParkingContext context = new SmartParkingContext())
                {
                    context.Brands.Add(brand);
                    context.SaveChanges();
                }
                response.Success = true;
                return(response);
            }
            catch (Exception ex)
            {
                response.Errors.Add("Erro no banco de dados contate o administrador");
                throw ex;
            }
        }
        public async Task <DataResponse <LocationDTO> > GetActives()
        {
            List <LocationDTO> locations = new List <LocationDTO>();

            try
            {
                using (SmartParkingContext context = new SmartParkingContext())
                {
                    locations = await context.Locations.Where(c => c.IsActive == true).ToListAsync();
                }
                DataResponse <LocationDTO> dataResponse = new DataResponse <LocationDTO>();
                dataResponse.Data    = locations;
                dataResponse.Success = true;
                return(dataResponse);
            }
            catch (Exception ex)
            {
                DataResponse <LocationDTO> response = new DataResponse <LocationDTO>();
                response.Success = false;
                response.Errors.Add("Falha ao acessar o banco de dados, contate o suporte.");
                return(response);
            }
        }
 public VehicleRepository(SmartParkingContext context)
 {
     _context = context;
 }
 public ClientService(IClientRepository iClientRep, SmartParkingContext context)
 {
     this._iClientRepository = iClientRep;
     this._context           = context;
 }
Esempio n. 6
0
 public ParkingSpotRepository(SmartParkingContext context)
 {
     _context = context;
 }
Esempio n. 7
0
 public ClientRepository(SmartParkingContext context)
 {
     _context = context;
 }
Esempio n. 8
0
 public EmployeeRepository(SmartParkingContext context)
 {
     _context = context;
 }
 public BrandRepository(SmartParkingContext context)
 {
     _context = context;
 }
 public ModelRepository(SmartParkingContext context)
 {
     _context = context;
 }
 public LocationRepository(SmartParkingContext context)
 {
     _context = context;
 }