public void Delete(int Id) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION repositorio = new RepositorioREGION(context); REGION _REGION = repositorio.GetById(Id); if (Equals(_REGION, null)) { throw new Exception(String.Concat("No se ha encontrado REGION con Id =", Id.ToString())); } _REGION.ACTIVO = false; context.SaveChanges(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, string NOMBRE) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION repositorio = new RepositorioREGION(context); REGION _REGION = repositorio.GetById(Id); if (Equals(_REGION, null)) { throw new Exception(String.Concat("No se ha encontrado REGION con Id =", Id.ToString())); } //properties if (!string.IsNullOrEmpty(NOMBRE)) { _REGION.NOMBRE = NOMBRE; } //parents context.SaveChanges(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public REGION GetByIdWithReferences(int ID) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION repositorio = new RepositorioREGION(context); return(repositorio.GetByIdWithReferences(ID)); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public List <REGION> GetAllWithReferences() { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION repositorio = new RepositorioREGION(context); return(repositorio.GetAllWithReferences().OrderBy(i => i.NOMBRE).ToList()); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public int Add(int ID, string NOMBRE) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION repositorio = new RepositorioREGION(context); if (repositorio.GetByFilter(ID, true).Any()) { throw new Exception("Ya existe una región con este ID"); } REGION _REGION = null; if (repositorio.GetByFilter(ID, false).Any()) { _REGION = repositorio.GetByFilter(ID, false).First(); _REGION.NOMBRE = NOMBRE; _REGION.ACTIVO = true; } else { _REGION = new Modelo.REGION(); _REGION.ID = ID; _REGION.NOMBRE = NOMBRE; _REGION.ACTIVO = true; context.AddObject("REGION", _REGION); } context.SaveChanges(); return(_REGION.ID); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public int Add(int REGIONId, string NOMBRE) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION _repositorioREGION = new RepositorioREGION(context); REGION _objREGION = _repositorioREGION.GetById(REGIONId); if (Equals(_objREGION, null)) { throw new Exception(String.Concat("No se ha encontrado REGION con Id =", REGIONId.ToString())); } COMUNA _COMUNA = new COMUNA(); //properties _COMUNA.NOMBRE = NOMBRE; _COMUNA.ACTIVO = true; //parents _COMUNA.REGION = _objREGION; context.AddObject("COMUNA", _COMUNA); context.SaveChanges(); return(_COMUNA.ID); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }