/// <summary>
        /// Get books for Home page
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public HomePageResponse GetHomePageBooks(HomePageRequest request)
        {
            HomePageResponse response = new HomePageResponse();

            response.TopRecent     = this.GetTopRecent(request.TakeBook);
            response.TopDownloaded = this.GetTopDownloaded(request.TakeBook);
            response.TopRated      = this.GetTopRated(request.TakeBook);
            return(response);
        }
Exemple #2
0
        private void On_Navigated()
        {
            JObject response = (JObject)resp;

            if (response == null)
            {
                return;
            }
            if (Type == ResponseType.Home)
            {
                HomePageResponse videoList = response.ToObject <HomePageResponse>();
                list = videoList.VideoList;
            }
            else if (Type == ResponseType.CourseList)
            {
                courseList = ((JObject)response).ToObject <CourseListResponse>().CourseList;
            }
            else if (Type == ResponseType.EditCourseVideo)
            {
                EditCourseVideosResponse videoList = response.ToObject <EditCourseVideosResponse>();
                list = videoList.videoList;
            }
            else if (Type == ResponseType.Favorites)
            {
                FavoritesResponse result = response.ToObject <FavoritesResponse>();
                list = result.VideoList;
            }
            else if (Type == ResponseType.Search)
            {
                SearchResponse r = response.ToObject <SearchResponse>();
                _searchType = r.Type;
                if (r.Type == SearchType.Course)
                {
                    if (r.CourseList != null)
                    {
                        courseList = r.CourseList;
                    }
                }
                else
                {
                    if (r.VideoList != null)
                    {
                        list = r.VideoList;
                    }
                }
            }
        }
        public HomePageResponse GetHomePageSummary()
        {
            HomePageResponse response = new HomePageResponse();

            using (StudentManagementPortalEntities dbContext = new StudentManagementPortalEntities())
            {
                var ownerDetails = new string[] { "Anish", "Lavish", "Vaibhav", "Gaurav" };

                var data = (from a in dbContext.Finances
                            group a by a.TransactionType into c
                            select new
                {
                    Type = c.Key,
                    Sum = c.Sum(pc => pc.Amount)
                });
                response.totalFinances = new Dictionary <string, decimal>();
                foreach (var item in data)
                {
                    response.totalFinances.Add(item.Type, item.Sum);
                }


                var ownerLibabilty = (from a in dbContext.Finances where ownerDetails.Contains(a.PaidTo)   group a by a.PaidTo into c select new {
                    Type = c.Key,
                    sum = c.Sum(pc => pc.Amount)
                });

                response.totalLibality = new Dictionary <string, decimal>();
                foreach (var item in ownerLibabilty)
                {
                    response.totalLibality.Add(item.Type, item.sum);
                }

                var students = (from a in dbContext.Students where a.CurrentStatus == "Active"   select a).ToList();
                response.totalActiveStudents = new Dictionary <string, decimal>();
                response.totalActiveStudents.Add("TotalActiveStudents", students.Count);
                var dueDate = students.Where(item => item.DueDate > DateTime.Now).ToList();
                response.dueDatePassed = new Dictionary <string, decimal>();
                response.dueDatePassed.Add("DueDateCount", dueDate.Count);
            }
            return(response);
        }
        public IActionResult GetMutualFundDetails()
        {
            var currentValue  = 0.0;
            var investedValue = 0.0;
            var change        = 0.0;
            var homeResponse  = new HomePageResponse();
            var stocksData    = _fundService.GetAllMutualFunds();

            foreach (var data in stocksData)
            {
                currentValue  = currentValue + data.CurrentInvestmentValue;
                investedValue = investedValue + data.TotalInvestmentValue;
            }
            homeResponse.profitLossFunds = Math.Round(currentValue - investedValue, 2);
            change = (homeResponse.profitLossFunds / currentValue) * 100;
            homeResponse.currentValueFunds = Math.Round(currentValue, 2);
            homeResponse.amountInFunds     = Math.Round(investedValue, 2);
            homeResponse.changeFunds       = Math.Round(change, 2);;
            return(Ok(homeResponse));
        }
        public IActionResult Get()
        {
            var currentValue  = 0.0;
            var investedValue = 0.0;
            var change        = 0.0;
            var homeResponse  = new HomePageResponse();
            var stocksData    = _stockService.GetAllStocksData();

            foreach (var data in stocksData)
            {
                currentValue  = currentValue + data.currentInvestmentValue;
                investedValue = investedValue + data.totalInvestmentValue;
            }
            homeResponse.profitLossStocks = Math.Round(currentValue - investedValue, 2);
            change = (homeResponse.profitLossStocks / currentValue) * 100;
            homeResponse.currentValueStocks = Math.Round(currentValue, 2);
            homeResponse.amountInStocks     = Math.Round(investedValue, 2);
            homeResponse.changeStocks       = Math.Round(change, 2);;
            return(Ok(homeResponse));
        }
Exemple #6
0
        public async Task <ReturnResponse> GetHomePage()
        {
            var homePageResponse   = new HomePageResponse();
            var allProducts        = _dataContext.Product;
            var allProductsGrouped = await allProducts.GroupBy(a => new { a.CategoryId, a.ProductName }).Select(b => new ProductCard()
            {
                CategoryId = b.Key.CategoryId, ProductName = b.Key.ProductName
            }).ToListAsync();

            var allProductsNotAssigned = await allProducts.Where(a => !a.AssignedTo.HasValue).GroupBy(a => new { a.CategoryId, a.ProductName }).Select(b => new ProductCard()
            {
                CategoryId = b.Key.CategoryId, ProductName = b.Key.ProductName, QuantityInStock = b.Count()
            }).ToListAsync();

            homePageResponse.ProductCards = allProductsNotAssigned;

            homePageResponse.ProductCards = allProductsGrouped.GroupJoin(homePageResponse.ProductCards, left => new { left.CategoryId, left.ProductName }, right => new { right.CategoryId, right.ProductName }, (a, b) => new
            {
                TableA = a,
                TableB = b
            }).SelectMany(p => p.TableB.DefaultIfEmpty(), (x, y) => new
            {
                TableAA = x.TableA,
                TableBB = y
            }).Select(c => new ProductCard()
            {
                CategoryId      = c.TableAA.CategoryId,
                ProductName     = c.TableAA.ProductName,
                QuantityInStock = (c.TableBB == null) ? c.TableAA.QuantityInStock : c.TableBB.QuantityInStock
            }).ToList();

            return(new ReturnResponse()
            {
                StatusCode = Utils.Success,
                StatusMessage = Utils.StatusMessageSuccess,
                ObjectValue = homePageResponse
            });
        }