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 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; } }
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 GetById(int ID) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioREGION repositorio = new RepositorioREGION(context); return repositorio.GetById(ID); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }