コード例 #1
0
        public PersonalInfoModel(User wrapper)
        {
            if (info == null)
            {
                info = new VoicerFilterModel();
            }

            info._gender_id       = wrapper.GenderId;
            info._country_id      = wrapper.CountryId;
            info._hobby_ids       = wrapper.UsersHobbyUsers.Select(x => x.UsersHobbyId).ToList();
            info._occupation_ids  = wrapper.UsersOccupationsUsers.Select(x => x.UsersOccupationsId).ToList();
            info._birthday        = wrapper.BirthDate;
            info._relation        = wrapper.RelationshipStatus;
            info._region          = wrapper.Region;
            info._language        = wrapper.Language;
            info._pub_birthday    = wrapper.BirthDatePublic;
            info._pub_gender      = wrapper.GenderPublic;
            info._pub_country     = wrapper.CountryPublic;
            info._pub_region      = wrapper.RegionPublic;
            info._pub_language    = wrapper.LanguagePublic;
            info._pub_occupations = wrapper.OccupationPublic;
            info._pub_relation    = wrapper.RelationshipStatusPublic;
            info._pub_hobby       = wrapper.InterestHobbyPublic;
            _img = wrapper.ImageURL;
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: SerGem811/IVoice
        public ActionResult SavePersonalInfo(VoicerFilterModel model)
        {
            PersonalInfoModel m = new PersonalInfoModel();

            m.info = model;
            if (_userRepository.Save(m.ToEntity(_userRepository.FirstOrDefault(x => x.Id == _userID))) > 0)
            {
                #region Hobby
                var itemsHobby       = _userHobbyRepository.LoadAndSelect(x => x.UserId == _userID, x => x, false);
                var itemsHobbyListId = itemsHobby.Select(x => x.Id).ToList();

                if (model._hobby_ids == null)
                {
                    model._hobby_ids = new List <int>()
                    {
                    }
                }
                ;

                foreach (var item in itemsHobby)
                {
                    if (!model._hobby_ids.Contains(item.Id))
                    {
                        _userHobbyRepository.Remove(item);
                    }
                }

                foreach (var item in model._hobby_ids)
                {
                    if (!itemsHobbyListId.Contains(item))
                    {
                        _userHobbyRepository.Save(new UsersHobbyUser()
                        {
                            UserId       = _userID,
                            UsersHobbyId = item
                        });
                    }
                }
                #endregion
                #region Occupation
                var itemsOccupation       = _userOccupationRepository.LoadAndSelect(x => x.UserId == _userID, x => x, false);
                var itemsOccupationListId = itemsOccupation.Select(x => x.Id).ToList();

                if (model._occupation_ids == null)
                {
                    model._occupation_ids = new List <int>()
                    {
                    }
                }
                ;

                foreach (var item in itemsOccupation)
                {
                    if (!model._occupation_ids.Contains(item.Id))
                    {
                        _userOccupationRepository.Remove(item);
                    }
                }

                foreach (var item in model._occupation_ids)
                {
                    if (!itemsOccupationListId.Contains(item))
                    {
                        _userOccupationRepository.Save(new UsersOccupationsUser()
                        {
                            UserId             = _userID,
                            UsersOccupationsId = item
                        });
                    }
                }
                #endregion
            }
            return(Json(new Message(TMessage.TRUE), JsonRequestBehavior.AllowGet));
        }