using Microsoft.EntityFrameworkCore; using REC_HUMA.CORE.Entities; using REC_HUMA.CORE.Interfaces; using REC_HUMA.INFRASTRUCTURE; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace REC_HUMA.INFRASTRUCTURE.Repositories { public class DistritoRepo : IDistritoRepo { private readonly RECHUMAContext _Context; public DistritoRepo(RECHUMAContext Context) { _Context = Context; } public async Task> GetDistritos() { try { var distritos = await _Context.Distrito.AsNoTracking().ToListAsync(); return distritos; } catch (Exception ex) { throw; } } public async Task GetDistrito(int IdDistrito) { try { var distrito = await _Context.Distrito.Where(s => s.IdDistrito == IdDistrito).FirstOrDefaultAsync(); return distrito; } catch (Exception ex) { throw; } } public async Task PutDistrito(Distrito distrito) { try { _Context.Distrito.Update(distrito); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw; } } public async Task PostDistrito(Distrito distrito) { try { _Context.Distrito.Add(distrito); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw; } } public async Task DeleteDistrito(int IdDistrito) { try { var distrito = _Context.Distrito.Where(s => s.IdDistrito == IdDistrito).FirstOrDefault(); _Context.Distrito.Remove(distrito); await _Context.SaveChangesAsync(); } catch (Exception ex) { throw; } } } }