/// <summary> /// Сохранение данных пользователя /// </summary> /// <param name="userId">Идентификатор пользователя</param> public void SaveUserDetails(Guid userId) { MembershipUser user = Membership.GetUser(userId); if (user != null) { if (StringExtensions.NotEmpty(PasswordTxt.Text)) { user.ChangePassword(user.GetPassword(), PasswordTxt.Text); } user.Email = EmailTxt.Text; Membership.UpdateUser(user); UserProfile userProfile; if (UserProfile.Exists(userId)) { userProfile = UserProfile.GetByUserId(userId); userProfile.FirstName = FirstNameTxt.Text.Trim(); userProfile.LastName = LastNameTxt.Text.Trim(); userProfile.MiddleName = MiddleNameTxt.Text.Trim(); userProfile.GenderId = ConvertExtentions.ToInt32(GenderDdl.SelectedValue).NullIf((int)Genders.Unknown); userProfile.Update(); } else { userProfile = new UserProfile { UserId = userId, FirstName = FirstNameTxt.Text.Trim(), LastName = LastNameTxt.Text.Trim(), MiddleName = MiddleNameTxt.Text.Trim(), GenderId = ConvertExtentions.ToInt32(GenderDdl.SelectedValue).NullIf((int)Genders.Unknown), }; userProfile.Id = UserProfile.Add(userProfile); } } }
public async Task <RssChannel> GetChannel(CancellationToken cancellationToken = default(CancellationToken)) { string username = contextAccessor.HttpContext.Request.Query["id"]; var channel = new RssChannel(); channel.Generator = "YInsights"; channel.Description = $"Feed for {username}"; channel.Title = "YInsights perosonalized feed"; channel.Language = new CultureInfo("en-US"); channel.PublicationDate = DateTime.Now; channel.TimeToLive = 5; var category = new RssCategory("articles"); channel.Categories.Add(category); channel.Image = new RssImage(new Uri("https://yinsights.torosent.com"), "YInsights", new Uri("https://yinsights.torosent.com/images/Logomakr_5r1SVn.png")); var baseUrl = string.Concat( contextAccessor.HttpContext.Request.Scheme, "://", contextAccessor.HttpContext.Request.Host.ToUriComponent() ); var feedUrl = string.Concat( contextAccessor.HttpContext.Request.Scheme, "://", contextAccessor.HttpContext.Request.Host.ToUriComponent(), contextAccessor.HttpContext.Request.PathBase.ToUriComponent(), contextAccessor.HttpContext.Request.Path.ToUriComponent(), contextAccessor.HttpContext.Request.QueryString.ToUriComponent()); channel.SelfLink = new Uri(feedUrl); channel.Link = channel.SelfLink; var items = new List <RssItem>(); var tuple = userArticleService.GetUserUnviewedArticles(username, null, null, -1, maxFeedItems); var articles = tuple.Item1.Take(maxFeedItems); foreach (var item in articles) { var rssItem = new RssItem(); rssItem.Author = "YInsights"; rssItem.Categories.Add(category); rssItem.Guid = new RssGuid(item.url, true); rssItem.Link = new Uri(item.url); rssItem.PublicationDate = ConvertExtentions.UnixTimeStampToDateTime(item.time); rssItem.Title = item.title; items.Add(rssItem); } channel.Items = items; return(channel); }