/* Obtiene todos los perfiles creados por un Usuario */

        /* Agregar un Investigador Privado */
        public long Post(M.Person persona)
        {
            O.Person BDPerson = new O.Person
            {
                Name = persona.Name,
                ProfesionDescription = persona.ProfesionDescription,
                Email            = persona.Email,
                Phone            = persona.Phone,
                City             = persona.City,
                Latitude         = persona.Latitude,
                Longitude        = persona.Longitude,
                Ciprin           = persona.Ciprin,
                Active           = false,
                CreationDate     = System.DateTime.Now.ToString(),
                CreationHourZone = System.TimeZoneInfo.Local.ToString(),
                Avatar           = "",
                NameAvatar       = "",
                Views            = 0,
                IdUser           = persona.IdUser
            };
            BD.People.Add(BDPerson);
            BD.SaveChanges();

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

            return(BDPerson.Id);
        }
Beispiel #2
0
        public bool Post(long idPerson)
        {
            bool R = false;

            try
            {
                O.Person BDPerson = BD.People.FirstOrDefault(x => x.Id == idPerson);
                BDPerson.Views = BDPerson.Views + 1;
                BD.SaveChanges();
                R = true;
            }
            catch { R = false; }
            return(R);
        }
        /* Elimina un Investigador Privado */
        public string Post(int idPerson)
        {
            string R = "";

            try
            {
                O.Person BDPerson = BD.People.FirstOrDefault(x => x.Id == idPerson);
                BD.People.Remove(BDPerson);
                BD.SaveChanges();

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

                R = BDPerson.NameAvatar;
            }
            catch { }
            return(R);
        }
        public bool Post(M.ParametrosPutAvatar parametrosPutAvatar)
        {
            bool S = false;

            try
            {
                O.Person persona = BD.People.FirstOrDefault(x => x.Id == parametrosPutAvatar.Id);
                persona.Avatar     = parametrosPutAvatar.DownloadURL;
                persona.NameAvatar = parametrosPutAvatar.FileName;
                BD.SaveChanges();
                S = true;
            }

            catch
            {
                S = false;
            }

            return(S);
        }
        /* Agregar un Investigador Privado */

        /* Activar/Desactivar Perfil */
        public bool Post(long idPerson)
        {
            bool R = false;

            try
            {
                O.Person BDPerson = BD.People.FirstOrDefault(x => x.Id == idPerson);
                if (BDPerson.Active)
                {
                    BDPerson.Active = false;
                    R = false;
                }

                else
                {
                    BDPerson.Active = true;
                    R = true;
                }
                BD.SaveChanges();
            }
            catch { }
            return(R);
        }