Ejemplo n.º 1
0
        /* Agregar un Profesional Afín */
        public long Post(M.OtherPerson otraPersona)
        {
            O.OtherPerson BDOtherPerson = new O.OtherPerson
            {
                Name                 = otraPersona.Name,
                Profesion            = otraPersona.Profesion,
                ProfesionDescription = otraPersona.ProfesionDescription,
                Email                = otraPersona.Email,
                Phone                = otraPersona.Phone,
                City                 = otraPersona.City,
                Latitude             = otraPersona.Latitude,
                Longitude            = otraPersona.Longitude,
                Ciprin               = otraPersona.Ciprin,
                Active               = false,
                CreationDate         = System.DateTime.Now.ToString("g"),
                CreationHourZone     = System.TimeZoneInfo.Local.ToString(),
                Avatar               = "",
                NameAvatar           = "",
                Views                = 0,
                IdUser               = otraPersona.IdUser
            };
            BD.OtherPersons.Add(BDOtherPerson);
            BD.SaveChanges();

            O.User BDUser = BD.Users.FirstOrDefault(x => x.Id == otraPersona.IdUser);
            BDUser.CountProfiles = BDUser.CountProfiles + 1;
            BD.SaveChanges();

            return(BDOtherPerson.Id);
        }
Ejemplo n.º 2
0
        public M.OtherPerson[] Get(string criterio)
        {
            var SOP   = BD.OtherPersons;
            var query = from OP in SOP
                        where ((OP.City.Contains(criterio)) && OP.Active)
                        select new { OP.Id, OP.Name, OP.Profesion, OP.ProfesionDescription, OP.Email, OP.Phone, OP.Latitude, OP.Longitude, OP.Ciprin, OP.CreationDate, OP.CreationHourZone, OP.Avatar, OP.Views, OP.User.Username };

            M.OtherPerson[] arrayOtherPerson = new M.OtherPerson[query.Count()];
            M.OtherPerson   temp;

            long i = 0;

            foreach (var item in query)
            {
                temp = new M.OtherPerson
                {
                    Id                   = item.Id,
                    Name                 = item.Name,
                    Profesion            = item.Profesion,
                    ProfesionDescription = item.ProfesionDescription,
                    Email                = item.Email,
                    Phone                = item.Phone,
                    Latitude             = item.Latitude,
                    Longitude            = item.Longitude,
                    Ciprin               = item.Ciprin,
                    CreationDate         = item.CreationDate,
                    CreationHourZone     = item.CreationHourZone,
                    Avatar               = item.Avatar,
                    Views                = item.Views,
                    Username             = item.Username
                };

                arrayOtherPerson[i] = temp;
                i++;
            }
            return(arrayOtherPerson);
        }