Exemplo n.º 1
0
        public UserViewModel UserInfo(int id)
        {
            Member       user  = (from mem in db.Member where mem.Id == id select mem).Single();
            Profile      prof  = (from pro in db.Profile where pro.Id == user.ProfileID select pro).Single();
            Demographics demo  = (from dem in db.Demographics where dem.Id == prof.DemographicsID select dem).Single();
            var          userv = Mapper.Map <UserViewModel>(user);

            userv.introduction = prof.introduction;
            userv.birthDate    = demo.birthDate;
            userv.gender       = demo.gender;
            userv.city         = demo.city;
            userv.state        = demo.state;
            userv.country      = demo.country;
            userv.Id           = user.Id;

            if (prof.Interests == null)
            {
                prof.Interests = new List <Interest>();
            }

            if (prof.Friends == null)
            {
                prof.Friends = new List <Friend>();
            }
            db.SaveChanges();

            userv.Interests = prof.Interests;
            userv.Friends   = prof.Friends;

            return(userv);
        }
Exemplo n.º 2
0
        public List <UserViewModel> UserViewList()
        {
            var memList = db.Member.ToList();
            List <UserViewModel> userList = new List <UserViewModel>();

            for (int i = 0; i < memList.Count; i++)
            {
                Member       memb  = memList.ElementAt(i);
                Profile      prof  = (from pro in db.Profile where pro.Id == memb.ProfileID select pro).Single();
                Demographics demo  = (from dem in db.Demographics where dem.Id == prof.DemographicsID select dem).Single();
                var          userv = Mapper.Map <UserViewModel>(memb);

                userv.introduction = prof.introduction;
                userv.birthDate    = demo.birthDate;
                userv.gender       = demo.gender;
                userv.city         = demo.city;
                userv.state        = demo.state;
                userv.country      = demo.country;
                userv.Id           = memb.Id;

                userList.Add(userv);
            }

            return(userList);
        }
Exemplo n.º 3
0
        public UserViewModel createUser(Member mem, Profile pro, Demographics dem)
        {
            Member       newMem  = mem;
            Profile      newProf = pro;
            Demographics newDemo = dem;

            newMem.dateJoined = DateTime.Now;
            newMem.lastLogin  = DateTime.Now;

            db.Demographics.Add(newDemo);
            db.SaveChanges();


            db.Member.Add(newMem);
            db.SaveChanges();

            newProf.assocDemographics = newDemo;
            newProf.DemographicsID    = newDemo.Id;
            newProf.assocMember       = newMem;
            db.Profile.Add(newProf);
            db.SaveChanges();

            db.SaveChanges();

            newMem.assocProfile = newProf;
            newMem.ProfileID    = newProf.Id;
            db.SaveChanges();

            var userv = Mapper.Map <UserViewModel>(newMem);

            userv.introduction = newProf.introduction;
            userv.birthDate    = newDemo.birthDate;
            userv.gender       = newDemo.gender;
            userv.city         = newDemo.city;
            userv.state        = newDemo.state;
            userv.country      = newDemo.country;
            userv.Id           = newMem.Id;

            return(userv);
        }
Exemplo n.º 4
0
        public UserViewModel createUser(Member mem, Profile pro, Demographics dem)
        {
            Member newMem = mem;
            Profile newProf = pro;
            Demographics newDemo = dem;

            newMem.dateJoined = DateTime.Now;
            newMem.lastLogin = DateTime.Now;

            db.Demographics.Add(newDemo);
            db.SaveChanges();

            db.Member.Add(newMem);
            db.SaveChanges();

            newProf.assocDemographics = newDemo;
            newProf.DemographicsID = newDemo.Id;
            newProf.assocMember = newMem;
            db.Profile.Add(newProf);
            db.SaveChanges();

            db.SaveChanges();

            newMem.assocProfile = newProf;
            newMem.ProfileID = newProf.Id;
            db.SaveChanges();

            var userv = Mapper.Map<UserViewModel>(newMem);

            userv.introduction = newProf.introduction;
            userv.birthDate = newDemo.birthDate;
            userv.gender = newDemo.gender;
            userv.city = newDemo.city;
            userv.state = newDemo.state;
            userv.country = newDemo.country;
            userv.Id = newMem.Id;

            return userv;
        }