Exemplo n.º 1
0
        public static People GetPeopleById(int personId)
        {
            if (personId <= 0)
            {
                throw new ArgumentException(Resources.Organization.MessageZeroAreaId);
            }

            People theData = null;

            try
            {
                PeopleTableAdapter       localAdapter = new PeopleTableAdapter();
                PeopleDS.PeopleDataTable theTable     = localAdapter.GetPersonById(personId);
                if (theTable != null && theTable.Rows.Count > 0)
                {
                    PeopleDS.PeopleRow theRow = theTable[0];
                    theData = FillRecord(theRow);
                }
            }
            catch (Exception exc)
            {
                log.Error("Ocurrió un error mientras se obtenía la persona de id: " + personId, exc);
                throw exc;
            }

            return(theData);
        }
Exemplo n.º 2
0
        public static List <People> GetPeopleForAutocomplete(int organizationId, int areaId, string filter)
        {
            string userName = HttpContext.Current.User.Identity.Name;

            List <People> theList = new List <People>();
            People        theData = null;

            try
            {
                PeopleTableAdapter       localAdapter = new PeopleTableAdapter();
                PeopleDS.PeopleDataTable theTable     = localAdapter.GetPeopleForAutocomplete(userName, organizationId, areaId, filter);
                if (theTable != null && theTable.Rows.Count > 0)
                {
                    foreach (PeopleDS.PeopleRow theRow in theTable)
                    {
                        theData = FillRecord(theRow);
                        theList.Add(theData);
                    }
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
            return(theList);
        }
Exemplo n.º 3
0
        public static int InsertPeople(People theClass)
        {
            if (theClass.OrganizationId <= 0)
            {
                throw new ArgumentException(Resources.Organization.MessageZeroOrganizationId);
            }

            PeopleTableAdapter localAdapter = new PeopleTableAdapter();

            int?   personId = 0;
            string userName = HttpContext.Current.User.Identity.Name;

            try
            {
                localAdapter.InsertPerson(userName, theClass.OrganizationId, theClass.AreaId, theClass.Name, theClass.Id, ref personId);
            }
            catch (Exception exc)
            {
                log.Error(Resources.People.MessageErrorCreatePerson, exc);
                throw new Exception(Resources.People.MessageErrorCreatePerson);
            }

            if ((int)personId <= 0)
            {
                log.Error(Resources.People.MessageErrorCreatePerson);
                throw new ArgumentException(Resources.People.MessageErrorCreatePerson);
            }

            return((int)personId);
        }
Exemplo n.º 4
0
        public static List <People> GetPeopleBySearch(string whereClause)
        {
            if (string.IsNullOrEmpty(whereClause))
            {
                whereClause = "1=1";
            }

            string userName = HttpContext.Current.User.Identity.Name;

            List <People> theList = new List <People>();
            People        theData = null;

            try
            {
                PeopleTableAdapter       localAdapter = new PeopleTableAdapter();
                PeopleDS.PeopleDataTable theTable     = localAdapter.GetPeopleBySearch(userName, whereClause);

                if (theTable != null && theTable.Rows.Count > 0)
                {
                    foreach (PeopleDS.PeopleRow theRow in theTable)
                    {
                        theData = FillRecord(theRow);
                        theList.Add(theData);
                    }
                }
            }
            catch (Exception exc)
            {
                log.Error("Error to obtain the people by search.");
                throw exc;
            }

            return(theList);
        }
Exemplo n.º 5
0
        public static void DeletePermanently(int personId)
        {
            PeopleTableAdapter adapter = new PeopleTableAdapter();

            try
            {
                adapter.DeletePermanentlyPerson(personId);
            }
            catch (Exception ex)
            {
                log.Error(Resources.People.MessageErrorDeletePerson, ex);
                throw new Exception(Resources.People.MessageErrorDeletePerson);
            }
        }
Exemplo n.º 6
0
        public static void UpdatePeople(People theClass)
        {
            if (theClass.OrganizationId <= 0)
            {
                throw new ArgumentException(Resources.Organization.MessageZeroOrganizationId);
            }

            PeopleTableAdapter localAdapter = new PeopleTableAdapter();

            try
            {
                localAdapter.UpdatePerson(theClass.PersonId, theClass.Id, theClass.Name, theClass.OrganizationId, theClass.AreaId);
            }
            catch (Exception exc)
            {
                log.Error(Resources.People.MessageErrorUpdatePerson, exc);
                throw new Exception(Resources.People.MessageErrorUpdatePerson);
            }
        }
Exemplo n.º 7
0
        public static void DeletePeople(int personId)
        {
            if (personId <= 0)
            {
                throw new ArgumentException(Resources.People.MessageIdPersonZero);
            }

            PeopleTableAdapter localAdapter = new PeopleTableAdapter();
            string             userName     = HttpContext.Current.User.Identity.Name;

            try
            {
                localAdapter.DeletePerson(personId, userName);
            }
            catch (Exception exc)
            {
                log.Error(Resources.People.MessageErrorDeletePerson, exc);
                throw new Exception(Resources.People.MessageErrorDeletePerson);
            }
        }