예제 #1
0
        public void UpdateUser(User user)
        {
            using (var db = new AdminDbContext())
            {
                var ent = db.Users.FirstOrDefault(e => e.UserId == user.UserId);
                if (ent == null) return;

                ent.UserName = user.UserName;
                ent.DisplayName = user.DisplayName;
                ent.Email = user.Email;

                db.SaveChanges();
            }
        }
예제 #2
0
        public static void UpdateUser(string username, User user)
        {
            user.UserId = GetUser(username).UserId;

            Provider.UpdateUser(user);
        }
예제 #3
0
        public ActionResult UserEdit(string username, UserEditModel model)
        {
            try
            {
                User user = new User
                {
                    UserName = model.UserName,
                    DisplayName = model.DisplayName,
                    Email = model.Email,
                };

                AccountManager.UpdateUser(username, user);

                return RedirectToAction("Users");
            }
            catch
            {
                return View();
            }
        }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="postEnt"></param>
        /// <param name="nav"></param>
        /// <param name="tagList"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        private static Article _MapArticle(PostEntity postEnt, Nav nav, List<Tag> tagList, User user)
        {
            var md = new MarkdownDeep.Markdown();

            return new Article(nav)
            {
                PostId = postEnt.PostId,
                PostGuidId = postEnt.PostGuidId,
                PostStatus = postEnt.PostStatus,
                UserId = postEnt.UserId,
                Author =  user.DisplayName,
                Email = user.Email,
                UserName = user.UserName,
                PostSlug = postEnt.Slug,
                Subject = WebHelper.HtmlDecode(postEnt.Subject), // TODO: should I decode here?
                Body = postEnt.Body,
                DateCreated = postEnt.DateCreated,
                DateUpdated = postEnt.DateUpdated,
                ViewCount = postEnt.ViewCount,
                IP = postEnt.IP,
                Tags = tagList,
            };
        }
예제 #5
0
        /// <summary>
        /// Returns a <see cref="Fan.Blogs.Post"/> given a <see cref="PostEntity"/>, maps to the post's specific type.
        /// </summary>
        /// <remarks>
        /// 
        /// </remarks>
        /// <exception cref="BlogException">If the PostType is not defined</exception>
        internal static Post MapPost(PostEntity postEnt, Nav nav, User user)
        {
            // take tags out from PostEntity
            List<Tag> tagList = new List<Tag>();
            foreach (var tagEnt in postEnt.TagEntities)
            {
                tagList.Add(new Tag(nav)
                {
                    TagId = tagEnt.TagId,
                    TagName = WebHelper.UrlDecode(tagEnt.Name),
                    PostCount = tagEnt.PostEntities.Count,
                    Description = tagEnt.Description,
                });
            }

            // fill in PostType specific post
            switch ((PostType)postEnt.PostType)
            {
                case PostType.Article: return _MapArticle(postEnt, nav, tagList, user);
                default: throw new SiteException("Not supported post type.");
            }
        }