Ejemplo n.º 1
0
        void EnforceAvatarRules()
        {
            var split = DisplayName.Split(';');

            if (split.Length != 2)
            {
                return;
            }
            DisplayName = split[0];
            Avatar      = split[1];
        }
        public CustomRider CreateRidePin()
        {
            var pin = new CustomRider()
            {
                Id          = string.IsNullOrEmpty(Id) ? UserPrincipalName : Id,
                Title       = GivenName,
                Description = GivenName
            };

            if (HasLocation())
            {
                pin.Longitude = Longitude.Value;
                pin.Latitude  = Latitude.Value;
            }

            pin.Color = ProfileColor;

            if (!string.IsNullOrEmpty(DisplayName))
            {
                var split = DisplayName.Split(' ');
                if (split.Any())
                {
                    pin.Acronym = string.Format("{0}{1}",
                                                split.First().Substring(0, 1),
                                                split.Last().Substring(0, 1));
                }
            }
            else
            {
                pin.Acronym = string.Format("{0}{1}",
                                            UserPrincipalName.Substring(0, 1),
                                            UserPrincipalName.Substring(1, 2));
            }


            return(pin);
        }
Ejemplo n.º 3
0
        public void Publish(string postid, string postTitle, string[] categories, BlogSetting blog)
        {
            if (categories == null)
            {
                categories = new string[0];
            }

            var proxy = getMetaWeblog(blog.WebAPI);

            var newpost = new Post();

            try
            {
                var renderBody = DocumentParser.GetBodyContents(Document.Text);

                if (string.IsNullOrWhiteSpace(postid))
                {
                    var permalink = DisplayName.Split('.')[0] == "New Document"
                                ? postTitle
                                : DisplayName.Split('.')[0];

                    newpost = new Post
                    {
                        permalink   = permalink,
                        title       = postTitle,
                        dateCreated = DateTime.Now,
                        description = blog.Language == "HTML" ? renderBody : Document.Text,
                        categories  = categories,
                        format      = blog.Language
                    };
                    newpost.postid = proxy.NewPost(blog, newpost, true);
                }
                else
                {
                    newpost             = proxy.GetPost(postid, blog);
                    newpost.title       = postTitle;
                    newpost.description = blog.Language == "HTML" ? renderBody : Document.Text;
                    newpost.categories  = categories;
                    newpost.format      = blog.Language;

                    proxy.EditPost(postid, blog, newpost, true);
                }
            }
            catch (WebException ex)
            {
                dialogService.ShowError("Error Publishing", ex.Message, "");
            }
            catch (XmlRpcException ex)
            {
                dialogService.ShowError("Error Publishing", ex.Message, "");
            }
            catch (XmlRpcFaultException ex)
            {
                dialogService.ShowError("Error Publishing", ex.Message, "");
            }

            Post     = newpost;
            Original = Document.Text;
            Title    = postTitle;
            NotifyOfPropertyChange(() => DisplayName);
        }