コード例 #1
0
        public int Create(TwitterAccountDTO model, int userId, string picBase64)
        {
            try
            {
                var account = this.unitOfWork.TwitterAccounts
                              .All()
                              .Where(ta => ta.TwitterId.Equals(model.IdString))
                              .FirstOrDefault();

                if (account == null)
                {
                    account = this.BuildTwitterAccountObject(model, userId, picBase64);

                    this.unitOfWork.TwitterAccounts.Add(account);
                }
                else
                {
                    account.Users.Add(new UserTwitterAccount()
                    {
                        UserId         = userId,
                        TwitterAccount = account
                    });
                }

                this.AddToAccountStatuses(account.TwitterId, account);

                this.unitOfWork.SaveChanges();

                return(account.Id);
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error", ex);
            }
        }
コード例 #2
0
        private TwitterAccount BuildTwitterAccountObject(TwitterAccountDTO model, int userId, string picBase64)
        {
            var account = this.mappingProvider.MapTo <TwitterAccount>(model);

            account.CreatedAt = DateTime.Now;
            account.Users.Add(new UserTwitterAccount()
            {
                UserId         = userId,
                TwitterAccount = account
            });

            if (!string.IsNullOrEmpty(picBase64))
            {
                account.TwitterAccountImage = new TwitterAccountImage()
                {
                    ProfileImage   = picBase64,
                    TwitterAccount = account
                };
            }

            return(account);
        }
コード例 #3
0
 public int Update(TwitterAccountDTO model)
 {
     throw new NotImplementedException();
 }