コード例 #1
0
        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;
            }
        }
コード例 #2
0
ファイル: TrxREGION.cs プロジェクト: preguntoncojonero/test
 public List<REGION> GetByFilter(string NOMBRE = "")
 {
     Init();
     try
     {
         using (LQCEEntities context = new LQCEEntities())
         {
             RepositorioREGION repositorio = new RepositorioREGION(context);
             return repositorio.GetByFilter(NOMBRE).OrderBy(i => i.ID).ToList();
         }
     }
     catch (Exception ex)
     {
          ISException.RegisterExcepcion(ex);
         Error = ex.Message;
         throw ex;
     }
 }