Exemplo n.º 1
0
        public IActionResult AppendAlias(string alias, int count)
        {
            var _alias = context.User.FirstOrDefault(x => x.Alias == alias);

            if (_alias == null)
            {
                count++;
                var array = new Data.DataModels.User[count];
                array[count - 1] = new Data.DataModels.User()
                {
                    Alias         = alias,
                    AspNetUsersId = _userManager.GetUserAsync(HttpContext.User).Result?.Id
                };
                return(PartialView("Alias", new Models.BlogViewModels.BlogAliasViewModel()
                {
                    UserAliases = array.ToList()
                }));
            }
            else
            {
                return(new JsonResult(new
                {
                    success = false,
                    message = "This Alias is allready in use, try a different one."
                }));
            }
        }
Exemplo n.º 2
0
        public IActionResult UserBlog(string alias = "")
        {
            var SelectedUser = new Data.DataModels.User()
            {
            };

            if (alias == "" && User.Identity.IsAuthenticated)
            {
                SelectedUser = context.User.Include("UserPosts.Post.PostTags").FirstOrDefault(x => x.AspNetUsersId == _userManager.GetUserAsync(HttpContext.User).Result.Id);
            }
            else
            {
                SelectedUser = context.User.Include("UserPosts.Post.PostTags").FirstOrDefault(x => x.Alias == alias);
            }
            var Posts = SelectedUser?.UserPosts?.Select(x => x.Post).ToList();

            return(View("Wall", new Models.BlogViewModels.Wall_ViewModel()
            {
                SelectedUser = SelectedUser,
                Posts = Posts,
            }));
        }