コード例 #1
0
ファイル: PinsService.cs プロジェクト: EchoPan/BreadcrumbAPI
        public Dictionary<string, object> StorePin(PinModel pin, Dictionary<string, Stream> files, string accessToken)
        {
            Dictionary<string, object> retval = new Dictionary<string, object>();
            try
            {
                //instance handlers
                IDataHelper db = Container.getInstance("dataHelper").Resolve<IDataHelper>();
                IS3Helper s3 = Container.getInstance("s3Helper").Resolve<IS3Helper>();
                IFacebookHelper fb = Container.getInstance("facebookHelper").Resolve<IFacebookHelper>();

                //get facebook profile and friend list
                dynamic fbProfile = fb.GetUserHeadshot(accessToken);
                pin.OwnerID = fbProfile.id;
                pin.OwnerHeadshot = fbProfile.picture.data.url;
                pin.OwnerName = fbProfile.name;

                //insert db
                pin.LastSyncDate = DateTime.UtcNow.ToUnixTimestamp();
                db.StorePin(pin.GenerateToDictionary());

                //upload to S3
                foreach (var item in files)
                {
                    if (!s3.Upload(pin.OwnerID, item.Key, item.Value))
                    {
                        //return false;
                    }
                }
                retval.Add("state", true);
                retval.Add("message", "");

            }
            catch (Exception ext)
            {

                retval.Add("state", false);
                retval.Add("message", ext.Message);
                throw;
            }
            return retval;
        }