Exemple #1
0
 public UserMeta Create(UserMeta model)
 {
     return _context.UserMeta.Add(model);
 }
Exemple #2
0
 public UserMeta Create(UserMeta model)
 {
     return _userMetaRepository.Create(model);
 }
Exemple #3
0
        public ActionResult Settings(FormCollection collection)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                var user = UserService.GetUser(User.Identity.Name);

                if (!string.IsNullOrWhiteSpace(collection["slug"]))
                {
                    user.Slug = collection["slug"];
                }
                if (!string.IsNullOrWhiteSpace(collection["website"]))
                {
                    user.Website = collection["website"];
                }
                if (!string.IsNullOrWhiteSpace(collection["Signature"]))
                {
                    user.Signature = collection["Signature"];
                }

                var metaList = new List<UserMeta>();

                var gender = new UserMeta();
                gender.MetaKey = AppConstants.UserGender;
                gender.MetaValue = collection[AppConstants.UserGender];
                metaList.Add(gender);

                var sexTrend = new UserMeta();
                sexTrend.MetaKey = AppConstants.UserSexTrend;
                sexTrend.MetaValue = collection[AppConstants.UserSexTrend];
                metaList.Add(sexTrend);

                var love = new UserMeta();
                love.MetaKey = AppConstants.UserLove;
                love.MetaValue = collection[AppConstants.UserLove];
                metaList.Add(love);

                var blood = new UserMeta();
                blood.MetaKey = AppConstants.UserBlood;
                blood.MetaValue = collection[AppConstants.UserBlood];
                metaList.Add(blood);

                var birthday = new UserMeta();
                birthday.MetaKey = AppConstants.UserBirthday;
                var birthdayValue = DateTime.UtcNow;
                DateTime.TryParse(collection[AppConstants.UserBirthday], out birthdayValue);
                birthday.MetaValue = birthdayValue.ToString();
                metaList.Add(birthday);

                var province = new UserMeta();
                province.MetaKey = AppConstants.UserProvince;
                province.MetaValue = collection[AppConstants.UserProvince];
                metaList.Add(province);

                var city = new UserMeta();
                city.MetaKey = AppConstants.UserCity;
                city.MetaValue = collection[AppConstants.UserCity];
                metaList.Add(city);

                var weibo = new UserMeta();
                weibo.MetaKey = AppConstants.UserWeibo;
                weibo.MetaValue = collection[AppConstants.UserWeibo];
                metaList.Add(weibo);

                var tencentWeibo = new UserMeta();
                tencentWeibo.MetaKey = AppConstants.UserTencentWeibo;
                tencentWeibo.MetaValue = collection[AppConstants.UserTencentWeibo];
                metaList.Add(tencentWeibo);

                var tencentQQ = new UserMeta();
                tencentQQ.MetaKey = AppConstants.UserTencentQQ;
                tencentQQ.MetaValue = collection[AppConstants.UserTencentQQ];
                metaList.Add(tencentQQ);

                var googlePlus = new UserMeta();
                googlePlus.MetaKey = AppConstants.UserGooglePlus;
                googlePlus.MetaValue = collection[AppConstants.UserGooglePlus];
                metaList.Add(googlePlus);

                var twitter = new UserMeta();
                twitter.MetaKey = AppConstants.UserTwitter;
                twitter.MetaValue = collection[AppConstants.UserTwitter];
                metaList.Add(twitter);

                var facebook = new UserMeta();
                facebook.MetaKey = AppConstants.UserFacebook;
                facebook.MetaValue = collection[AppConstants.UserFacebook];
                metaList.Add(facebook);

                user.UserMeta = metaList;
                user = _userMetaService.Create(user);

                try
                {
                    unitOfWork.SaveChanges();
                    unitOfWork.Commit();

                    var result = new LoginMessageViewModel();
                }
                catch (Exception ex)
                {
                    LoggingService.Error(ex);
                }

                return View(user);
            }
        }