Esempio n. 1
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var dataSource = services.GetRequiredService <DataSource>();
                    dataSource.Comments = HTTPRequests.GetComments();

                    dataSource.Posts = LinqRequests.GetPostsEntity(HTTPRequests.GetPosts()
                                                                   , dataSource.Comments);

                    dataSource.Todos = HTTPRequests.GetTodos();

                    dataSource.Users = LinqRequests.GetUsersEntity(HTTPRequests.GetUsers()
                                                                   , dataSource.Posts, dataSource.Todos);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while creating data source.");
                }
            }

            host.Run();
        }
Esempio n. 2
0
        //GET: /DataRequest/GetAdditionalUserInfo
        public IActionResult GetAdditionalUserInfo(int id)
        {
            if (!dataSource.Users.Exists(u => u.Id == id))
            {
                return(Redirect($"~/DataRequest/Info?actionId=5&message=User with this id {id} doesn't exist !"));
            }

            var res = LinqRequests.GetAdditionalUserInfo(id, dataSource.Users);

            return(View(res));
        }
Esempio n. 3
0
        //GET: /DataRequest/GetAdditionalPostInfo
        public IActionResult GetAdditionalPostInfo(int id)
        {
            if (!dataSource.Posts.Exists(p => p.Id == id))
            {
                return(Redirect($"~/DataRequest/Info?actionId=6&message=Post with this id {id} doesn't exist !"));
            }

            var res = LinqRequests.GetAdditionalPostInfo(id, dataSource.Posts);

            return(View(res));
        }
Esempio n. 4
0
        //GET: /DataRequest/GetCommentsCount
        public IActionResult GetCommentsCount(int id)
        {
            if (!dataSource.Users.Exists(u => u.Id == id))
            {
                return(Redirect($"~/DataRequest/Info?actionId=1&message=User with this id {id} doesn't exist !"));
            }

            var commentsCount = LinqRequests.CommentsCount(id, dataSource.Posts);

            return(View(commentsCount));
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var listService = new ListGenerator();
            var People      = new List <Person>();
            var Payments    = new List <Payment>();

            listService.CreateListOfPeople(People, numOfPeople: 1000);
            listService.CreateListOfPayments(Payments, numOfPayments: 10000, numOfPeople: 1000);

            var xmlPeople = new XMLSerializator <List <Person> >(ConfigurationManager.AppSettings["BaseOfNames"]);

            xmlPeople.Write(People);

            var xmlPayments = new XMLSerializator <List <Payment> >(ConfigurationManager.AppSettings["BaseOfPayments"]);

            xmlPayments.Write(Payments);

            var request = new LinqRequests();

            request.LastMonthPayments();
            //request.MaxAveragePayment();
            //request.UserSumPayments(45);
            //request.Top3MaxAndMin();
        }
Esempio n. 6
0
        //GET: /DataRequest/GetSortedUsers
        public IActionResult GetSortedUsers()
        {
            var res = LinqRequests.GetSortedUsers(dataSource.Users);

            return(View(res));
        }
Esempio n. 7
0
        //GET: /DataRequest/Posts
        public IActionResult Posts()
        {
            var res = LinqRequests.GetPostUserList(dataSource.Posts, dataSource.Users);

            return(View(res));
        }
Esempio n. 8
0
        //GET: /DataRequest/PostInfo
        public IActionResult PostInfo(int id)
        {
            var res = LinqRequests.GetPostUserList(dataSource.Posts, dataSource.Users).FirstOrDefault(t => t.Post.Id == id);

            return(View(res));
        }