Beispiel #1
0
        public void AddHome(AddHomeBindingModel home)
        {
            var homeToAdd = AutoMapper.Mapper.Map <AddHomeBindingModel, Home>(home);

            if (home.ProfilePicture != null)
            {
                var profilePicture = PictureHelper.ConvertToBytes(home.ProfilePicture);

                string linkToProfilePicture = String.Empty;
                using (var dbx = new DropboxClient(DropboxHelper.AccessToken))
                {
                    linkToProfilePicture = DropboxHelper.Upload(dbx, "/Homes/" + home.Name, "profile.png", profilePicture).ToString();
                }

                homeToAdd.ProfilePicture = linkToProfilePicture;
            }
            else
            {
                homeToAdd.ProfilePicture = "/Defaults/home.png";
            }

            GeocodingHelper.SetLocation(homeToAdd.Location);
            homeToAdd.PostedDate = DateTime.Now;
            repository.Insert(homeToAdd);
            this.repository.Commit();
        }