Beispiel #1
0
        public async Task <IActionResult> OnGetAsync(Guid TechId)
        {
            TechPost = await _repo.GetTechPostForUser(TechId);

            if (TechPost == null)
            {
                return(RedirectToPage("Index"));
            }

            return(Page());
        }
        public void AddTechBlogPost(string UserId, TechPost TPost)
        {
            var user = GetUser(UserId);

            if (user != null)
            {
                if (TPost.TechId == Guid.Empty)
                {
                    TPost.TechId = Guid.NewGuid();
                }
                user.TechPosts.Add(TPost);
            }
        }
Beispiel #3
0
        public async Task Seed()
        {
            _ctx.Database.EnsureCreated();

            var user = await _userManager.FindByEmailAsync("*****@*****.**");

            var user1 = await _userManager.FindByEmailAsync("*****@*****.**");

            if (user == null)
            {
                user = new User()
                {
                    FirstName = "Urgen",
                    LastName  = "Dorjee",
                    UserName  = "******",
                    Email     = "*****@*****.**"
                };

                user1 = new User()
                {
                    FirstName = "Kalsang",
                    LastName  = "Nyima",
                    UserName  = "******",
                    Email     = "*****@*****.**"
                };
                var result1 = await _userManager.CreateAsync(user1, "Passw0rd!");

                var result = await _userManager.CreateAsync(user, "Passw0rd!");

                if (result1 != IdentityResult.Success)
                {
                    throw new InvalidOperationException("Failed to create a default user");
                }

                if (result != IdentityResult.Success)
                {
                    throw new InvalidOperationException("Failed to create a default user");
                }
            }
            if (!_ctx.TechPosts.Any())
            {
                var post = new TechPost()
                {
                    Title           = "Asp.Net Core 2.1 Road Map",
                    Description     = "Microsoft started to ship Asp.Net way back in early 2000 and since then it has been matured quite significantly,it has not much room left to ramp up, therefore the have started to build Asp.Net core from the scratch",
                    PostCreatedDate = DateTime.Now,
                    User            = user
                };
                var post1 = new TechPost()
                {
                    Title           = "MS Build 2018 Redmond Washington",
                    Description     = "Microsoft instroduced Signal R in Asp.Net Core 2.1",
                    PostCreatedDate = DateTime.Now,
                    User            = user,
                };
                var post2 = new TechPost()
                {
                    Title           = "WASM with Blazor",
                    Description     = "It is a great opportunity to a new developer, who can learn new technology that Microsoft come up with.",
                    PostCreatedDate = DateTime.Now,
                    User            = user1
                };
                _ctx.TechPosts.AddRange(post);
                _ctx.TechPosts.AddRange(post1);
                _ctx.TechPosts.AddRange(post2);


                _ctx.SaveChanges();
            }

            if (!_ctx.TravelPosts.Any())
            {
                var travel = new TravelPost()
                {
                    Title           = "Ravangla Road Trip 2018",
                    Description     = "I have been to this place many times since it is my home town, however i have been moved to different place now but what used to be look and feel of this place has been completely overhaul and sometimes feel that I find myself in different place",
                    PostCreatedDate = DateTime.Now,
                    User            = user
                };

                var travel1 = new TravelPost()
                {
                    Title           = "His Holiness Birthday Celebration",
                    Description     = "It is a great pride and auspicious occasion that Tibetan all over the world Celebrate the living embodiment of Avalokiteshwara HH the Dalai Lama birthday, We all tibetan feel undue of his relentless,tireless effort to keep the flame of tibet independence around the world arena.The man of peace is not only love by Tibetan but by most of the countries",
                    PostCreatedDate = DateTime.Now,
                    User            = user1
                };
                _ctx.TravelPosts.AddRange(travel);
                _ctx.TravelPosts.AddRange(travel1);
                _ctx.SaveChanges();
            }
        }
 public void UpdateTechPostForUser(TechPost TPost)
 {
     //no code in this implementation..
 }
 public void DeleteTechPost(TechPost TPost)
 {
     _ctx.TechPosts.Remove(TPost);
 }