Exemplo n.º 1
0
 public DoctorStatusReport()
 {
     PagingFilteringContext = new ReportPagingFilteringModel();
     ReportSearchModel = new ReportSearchModel();
     Data = new List<DoctorStatus>();
 }
Exemplo n.º 2
0
 public MonthlyCallByMrReport()
 {
     PagingFilteringContext = new ReportPagingFilteringModel();
     ReportSearchModel = new ReportSearchModel();
     Data = new List<MonthlyCallByMr>();
 }
Exemplo n.º 3
0
 public CommonTargetActualSalesReport()
 {
     PagingFilteringContext = new ReportPagingFilteringModel();
     ReportSearchModel = new ReportSearchModel();
     Data = new List<CommonTargetActualSales>();
 }
Exemplo n.º 4
0
 public DetailSalesReport()
 {
     PagingFilteringContext = new ReportPagingFilteringModel();
     ReportSearchModel = new ReportSearchModel();
     Data = new List<DetailSales>();
 }
Exemplo n.º 5
0
 public MonthlySalesForceSalesReport()
 {
     PagingFilteringContext = new ReportPagingFilteringModel();
     ReportSearchModel = new ReportSearchModel();
     Data = new List<MonthlySalesForceSales>();
 }
Exemplo n.º 6
0
 public MonthlyTerritoryManagementReport()
 {
     PagingFilteringContext = new ReportPagingFilteringModel();
     ReportSearchModel = new ReportSearchModel();
     Data = new List<MonthlyTerritoryManagement>();
 }
Exemplo n.º 7
0
        public ActionResult QuarterlyCallsByMr(ReportPagingFilteringModel command, [Bind(Prefix = "ReportSearchModel")]ReportSearchModel salesDataSearchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCallsAndVisits))
                return AccessDeniedView();

            if (command.PageSize <= 0) command.PageSize = _pageSize;
            if (command.PageNumber <= 0) command.PageNumber = 1;

            MonthlyCallByMrReport model = new MonthlyCallByMrReport();

            if (salesDataSearchModel == null)
            {
                salesDataSearchModel = new ReportSearchModel();
                salesDataSearchModel.Year = DateTime.Now.Year;

            }

            model.ReportSearchModel = salesDataSearchModel;

            var mrs = from item in _dataContext.Mrs
                      where item.MrCode.ToUpper() != "NA"
                      select item;

            if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators") || _workContext.CurrentCustomer.IsInCustomerRole("Management"))
            {
                //all
            }
            else
            {
                if (_workContext.CurrentCustomer.IsInCustomerRole("MrManagers"))
                {
                    mrs = from item in mrs
                          where (item.MrManagerId.HasValue && item.Mr1.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower())
                          || item.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower()
                          select item;
                }
                else
                {
                    mrs = from item in mrs
                          where item.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower()
                          select item;
                }
            }
            var mrsList = from item in mrs
                          select new SelectListItem
                          {
                              Value = item.MrId.ToString(),
                              Text = item.MrCode + " - " + item.MrName
                          };
            model.ReportSearchModel.Mrs = mrsList.ToList();
            model.ReportSearchModel.Mrs.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var query = from item in _dataContext.Transactions
                        where item.FigureTypeId == (int)FigureTypeEnum.Visit
                        && item.ScenarioId == (int)ScenarioEnum.Actual
                        && item.Date.Year == salesDataSearchModel.Year
                        select item;

            if (model.ReportSearchModel.MrId >= 0)
            {
                query = from item in query
                        where item.MrId == model.ReportSearchModel.MrId
                        select item;
            }
            else
            {
                if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators") || _workContext.CurrentCustomer.IsInCustomerRole("Management"))
                {

                }
                else
                {
                    //MR Manager
                    query = from item in query
                            where item.Mr.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower()
                            || (item.Mr.MrManagerId.HasValue && item.Mr.Mr1.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower())
                            select item;

                }

            }

            var groups = from item in query
                         group item by new
                         {
                             item.Mr.MrCode,
                             item.Date.Month
                         } into aGroup
                         select aGroup;

            IList<MonthlyCallByMr> list = new List<MonthlyCallByMr>();
            foreach (var item in groups)
            {
                MonthlyCallByMr details = new MonthlyCallByMr();
                details.MrCode = item.First().Mr.MrCode;
                details.MrName = item.First().Mr.MrName;
                details.Month = item.First().Date.Month.ToString();
                details.NumberOfCalls = item.Count();
                list.Add(details);
            }

            var data = new PagedList<MonthlyCallByMr>(list, command.PageNumber - 1, int.MaxValue);

            model.Data = data;
            model.PagingFilteringContext.LoadPagedList(data);

            return View(model);
        }
Exemplo n.º 8
0
        public ActionResult MonthlyTerritoryManagement(ReportPagingFilteringModel command, [Bind(Prefix = "ReportSearchModel")]ReportSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageActualSales))
                return AccessDeniedView();

            if (command.PageSize <= 0) command.PageSize = _pageSize;
            if (command.PageNumber <= 0) command.PageNumber = 1;

            MonthlyTerritoryManagementReport model = new MonthlyTerritoryManagementReport();

            if (searchModel == null)
            {
                searchModel = new ReportSearchModel();
                searchModel.FromDate = new DateTime(DateTime.Now.Year, 1, 1);
                searchModel.ToDate = new DateTime(DateTime.Now.Year, 12, 31);
            }

            model.ReportSearchModel = searchModel;
            //Avaiable list
            var distributors = from item in _dataContext.Distributors
                               select new SelectListItem
                               {
                                   Value = item.DistributorId.ToString(),
                                   Text = item.DistributorCode + " - " + item.DistributorName
                               };
            model.ReportSearchModel.Distributors = distributors.ToList();
            model.ReportSearchModel.Distributors.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var clients = from item in _dataContext.Clients
                          where item.IsStandard == true
                          select new SelectListItem
                          {
                              Value = item.ClientId.ToString(),
                              Text = item.ClientCode + " - " + item.ClientName
                          };
            model.ReportSearchModel.Clients = clients.ToList();
            model.ReportSearchModel.Clients.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var provinces = from item in _dataContext.Provinces
                            select new SelectListItem
                            {
                                Value = item.ProvinceId.ToString(),
                                Text = item.ProvinceName
                            };
            model.ReportSearchModel.Provinces = clients.ToList();
            model.ReportSearchModel.Provinces.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var Regions = from item in _dataContext.Regions
                          select new SelectListItem
                          {
                              Value = item.RegionId.ToString(),
                              Text = item.RegionName
                          };
            model.ReportSearchModel.Regions = clients.ToList();
            model.ReportSearchModel.Regions.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var mrs = from item in _dataContext.Mrs
                      select item;

            if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators") || _workContext.CurrentCustomer.IsInCustomerRole("Management"))
            {
            }
            else
            {

                if (_workContext.CurrentCustomer.IsInCustomerRole("MrManagers"))
                {
                    mrs = from item in mrs
                          where item.SalesTeam.SalesTeamCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower()
                          select item;
                }
                else
                {
                    var sharedMrs = from item in _dataContext.AllocationShares
                                    where item.Mr.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower()
                                    select item.Allocation.MrId;

                    mrs = from item in mrs
                          where item.MrCode.ToLower() == _workContext.CurrentCustomer.Username.ToLower()
                          || sharedMrs.Contains(item.MrId)
                          select item;
                }
            }

            var mrsList = from item in mrs
                          select new SelectListItem
                          {
                              Value = item.MrId.ToString(),
                              Text = item.MrCode + " - " + item.MrName
                          };
            model.ReportSearchModel.Mrs = mrsList.ToList();

            if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators") || _workContext.CurrentCustomer.IsInCustomerRole("Management"))
            {
                model.ReportSearchModel.Mrs.Insert(0, new SelectListItem { Text = "All", Value = "-1" });
            }

            var items = from item in _dataContext.Items
                        select new SelectListItem
                        {
                            Value = item.ItemId.ToString(),
                            Text = item.Sku + " - " + item.ItemName
                        };
            model.ReportSearchModel.Items = items.ToList();
            model.ReportSearchModel.Items.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var query = from item in _dataContext.Transactions
                        where item.FigureTypeId == (int)FigureTypeEnum.Sales
                        && (item.ScenarioId == (int)ScenarioEnum.Actual
                        || item.ScenarioId == (int)ScenarioEnum.Plan
                        || item.ScenarioId == (int)ScenarioEnum.Potential)
                        select item;

            if (model.ReportSearchModel.FromDate != null)
            {
                query = from item in query
                        where item.Date >= model.ReportSearchModel.FromDate
                        select item;
            }

            if (model.ReportSearchModel.ToDate != null)
            {
                query = from item in query
                        where item.Date <= model.ReportSearchModel.ToDate
                        select item;
            }

            if (model.ReportSearchModel.DistributorId > 0)
            {
                query = from item in query
                        where item.DistributorId == model.ReportSearchModel.DistributorId
                        select item;
            }

            if (model.ReportSearchModel.ClientId >= 0)
            {
                query = from item in query
                        where item.ClientId == model.ReportSearchModel.ClientId
                        select item;
            }

            if (model.ReportSearchModel.MrId >= 0)
            {
                query = from item in query
                        where item.MrId == model.ReportSearchModel.MrId
                        select item;
            }

            if (model.ReportSearchModel.ItemId >= 0)
            {
                query = from item in query
                        where item.ItemId == model.ReportSearchModel.ItemId
                        select item;
            }

            var summaryQuery = from record in query
                               group record by new
                               {
                                   ItemId = record.ItemId,
                                   MrId = record.MrId,
                                   ClientId = record.ClientId

                               } into aGroup
                               select aGroup;

            IList<MonthlyTerritoryManagement> list = new List<MonthlyTerritoryManagement>();
            foreach (var group in summaryQuery)
            {
                MonthlyTerritoryManagement item = new MonthlyTerritoryManagement();
                var first = group.First();
                item.Sku = first.Item.Sku;
                item.ItemName = first.Item.ItemName;
                item.MrCode = first.Mr.MrCode;
                item.MrName = first.Mr.MrName;
                item.SalesTeamName = first.Mr.SalesTeam.SalesTeamName;
                item.ClientTypeName = first.Client.ClientType.ClientTypeName;
                item.ClientCode = first.Client.ClientCode;
                item.ClientName = first.Client.ClientName;
                item.ClientRegionName = first.Client.Province.Region.RegionName;
                item.Agency = first.Client.Agency;
                item.Specialty = first.Client.Specialty;
                item.Grade = first.Client.Grade;
                item.NumberOfBeds = first.Client.NumberOfBeds;

            //LatestSellingPrice { get; set; }
            //LatestTender { get; set; }
            //LatestTenderPrice { get; set; }

                item.ActualQty01 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 1).Sum(a => a.Quantity);
                item.ActualQty02 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 2).Sum(a => a.Quantity);
                item.ActualQty03 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 3).Sum(a => a.Quantity);
                item.ActualQty04 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 4).Sum(a => a.Quantity);
                item.ActualQty05 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 5).Sum(a => a.Quantity);
                item.ActualQty06 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 6).Sum(a => a.Quantity);
                item.ActualQty07 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 7).Sum(a => a.Quantity);
                item.ActualQty08 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 8).Sum(a => a.Quantity);
                item.ActualQty09 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 9).Sum(a => a.Quantity);
                item.ActualQty10 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 10).Sum(a => a.Quantity);
                item.ActualQty11 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 11).Sum(a => a.Quantity);
                item.ActualQty12 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 12).Sum(a => a.Quantity);

                item.ActualAmt01 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 1).Sum(a => a.NetAmount);
                item.ActualAmt02 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 2).Sum(a => a.NetAmount);
                item.ActualAmt03 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 3).Sum(a => a.NetAmount);
                item.ActualAmt04 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 4).Sum(a => a.NetAmount);
                item.ActualAmt05 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 5).Sum(a => a.NetAmount);
                item.ActualAmt06 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 6).Sum(a => a.NetAmount);
                item.ActualAmt07 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 7).Sum(a => a.NetAmount);
                item.ActualAmt08 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 8).Sum(a => a.NetAmount);
                item.ActualAmt09 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 9).Sum(a => a.NetAmount);
                item.ActualAmt10 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 10).Sum(a => a.NetAmount);
                item.ActualAmt11 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 11).Sum(a => a.NetAmount);
                item.ActualAmt12 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 12).Sum(a => a.NetAmount);

                list.Add(item);
            }

            var data = new PagedList<MonthlyTerritoryManagement>(list, command.PageNumber - 1, command.PageSize);

            model.Data = data;
            model.PagingFilteringContext.LoadPagedList(data);

            return View(model);
        }
Exemplo n.º 9
0
        public ActionResult MonthlyDistributorSales(ReportPagingFilteringModel command, [Bind(Prefix = "ReportSearchModel")]ReportSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageActualSales))
                return AccessDeniedView();

            if (command.PageSize <= 0) command.PageSize = _pageSize;
            if (command.PageNumber <= 0) command.PageNumber = 1;

            MonthlyDistributorSalesReport model = new MonthlyDistributorSalesReport();

            if (searchModel == null)
            {
                searchModel = new ReportSearchModel();
                searchModel.FromDate = new DateTime(DateTime.Now.Year, 1, 1);
                searchModel.ToDate = new DateTime(DateTime.Now.Year, 12, 31);
            }

            model.ReportSearchModel = searchModel;
            //Avaiable list
            var channels = from item in _dataContext.Channels
                           select new SelectListItem
                           {
                               Value = item.ChannelId.ToString(),
                               Text = item.ChannelCode + "-" + item.ChannelName
                           };

            model.ReportSearchModel.Channels = channels.ToList();
            model.ReportSearchModel.Channels.Insert(0, new SelectListItem { Text = "All", Value = "-1"  });

            var distributors = from item in _dataContext.Distributors
                               select new SelectListItem
                               {
                                   Value = item.DistributorId.ToString(),
                                   Text = item.DistributorCode + " - " + item.DistributorName
                               };
            model.ReportSearchModel.Distributors = distributors.ToList();
            model.ReportSearchModel.Distributors.Insert(0, new SelectListItem { Text = "All", Value = "-1" });

            var query = from item in _dataContext.Transactions
                        where item.FigureTypeId == (int)FigureTypeEnum.Sales
                        && item.ScenarioId == (int)ScenarioEnum.Actual
                        select item;

            if (model.ReportSearchModel.FromDate != null)
            {
                query = from item in query
                        where item.Date >= model.ReportSearchModel.FromDate
                        select item;
            }

            if (model.ReportSearchModel.ToDate != null)
            {
                query = from item in query
                        where item.Date <= model.ReportSearchModel.ToDate
                        select item;
            }

            if (model.ReportSearchModel.ChannelId >= 0)
            {
                query = from item in query
                        where item.Client.ChannelId == model.ReportSearchModel.ChannelId
                        select item;
            }

            if (model.ReportSearchModel.DistributorId >= 0)
            {
                query = from item in query
                        where item.DistributorId == model.ReportSearchModel.DistributorId
                        select item;
            }

            var summaryQuery = from record in query
                               group record by new
                               {
                                   DistributorId = record.DistributorId

                               } into aGroup
                               select aGroup;

            IList<MonthlyDistributorSales> list = new List<MonthlyDistributorSales>();
            foreach (var group in summaryQuery)
            {
                MonthlyDistributorSales item = new MonthlyDistributorSales();
                var first = group.First();
                item.DistributorCode = first.Distributor.DistributorCode;
                item.DistributorName = first.Distributor.DistributorName;

                //LatestSellingPrice { get; set; }
                //LatestTender { get; set; }
                //LatestTenderPrice { get; set; }

                item.ActualQty01 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 1).Sum(a => a.Quantity);
                item.ActualQty02 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 2).Sum(a => a.Quantity);
                item.ActualQty03 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 3).Sum(a => a.Quantity);
                item.ActualQty04 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 4).Sum(a => a.Quantity);
                item.ActualQty05 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 5).Sum(a => a.Quantity);
                item.ActualQty06 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 6).Sum(a => a.Quantity);
                item.ActualQty07 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 7).Sum(a => a.Quantity);
                item.ActualQty08 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 8).Sum(a => a.Quantity);
                item.ActualQty09 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 9).Sum(a => a.Quantity);
                item.ActualQty10 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 10).Sum(a => a.Quantity);
                item.ActualQty11 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 11).Sum(a => a.Quantity);
                item.ActualQty12 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 12).Sum(a => a.Quantity);

                item.ActualAmt01 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 1).Sum(a => a.TotalAmount);
                item.ActualAmt02 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 2).Sum(a => a.TotalAmount);
                item.ActualAmt03 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 3).Sum(a => a.TotalAmount);
                item.ActualAmt04 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 4).Sum(a => a.TotalAmount);
                item.ActualAmt05 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 5).Sum(a => a.TotalAmount);
                item.ActualAmt06 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 6).Sum(a => a.TotalAmount);
                item.ActualAmt07 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 7).Sum(a => a.TotalAmount);
                item.ActualAmt08 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 8).Sum(a => a.TotalAmount);
                item.ActualAmt09 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 9).Sum(a => a.TotalAmount);
                item.ActualAmt10 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 10).Sum(a => a.TotalAmount);
                item.ActualAmt11 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 11).Sum(a => a.TotalAmount);
                item.ActualAmt12 = group.Where(a => a.ScenarioId == (int)ScenarioEnum.Actual && a.Date.Month == 12).Sum(a => a.TotalAmount);

                list.Add(item);
            }

            var data = new PagedList<MonthlyDistributorSales>(list, command.PageNumber - 1, command.PageSize);

            model.Data = data;
            model.PagingFilteringContext.LoadPagedList(data);

            return View(model);
        }
Exemplo n.º 10
0
        public ActionResult MonthlyCallsByDoctorGrade(ReportPagingFilteringModel command, [Bind(Prefix = "ReportSearchModel")]ReportSearchModel salesDataSearchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCallsAndVisits))
                return AccessDeniedView();

            if (command.PageSize <= 0) command.PageSize = _pageSize;
            if (command.PageNumber <= 0) command.PageNumber = 1;

            MonthlyCallByDoctorGradeReport model = new MonthlyCallByDoctorGradeReport();

            if (salesDataSearchModel == null)
            {
                salesDataSearchModel = new ReportSearchModel();
                salesDataSearchModel.Year = DateTime.Now.Year;

            }

            model.ReportSearchModel = salesDataSearchModel;

            var query = from item in _dataContext.Transactions
                        where item.FigureTypeId == (int)FigureTypeEnum.Visit
                        && item.ScenarioId == (int)ScenarioEnum.Actual
                        && item.Date.Year == salesDataSearchModel.Year
                        select item;

            var groups = from item in query
                         group item by new
                         {
                             item.Doctor.DoctorGrade.DoctorGradeValue,
                             item.Date.Month
                         } into aGroup
                         select aGroup;

            IList<MonthlyCallByDoctorGrade> list = new List<MonthlyCallByDoctorGrade>();
            foreach (var item in groups)
            {
                MonthlyCallByDoctorGrade details = new MonthlyCallByDoctorGrade();
                details.DoctorGradeValue = item.First().Doctor.DoctorGrade.DoctorGradeValue;
                details.Month = item.First().Date.Month.ToString();
                details.NumberOfCalls = item.Count();
                list.Add(details);
            }

            var data = new PagedList<MonthlyCallByDoctorGrade>(list, command.PageNumber - 1, int.MaxValue);

            model.Data = data;
            model.PagingFilteringContext.LoadPagedList(data);

            return View(model);
        }
Exemplo n.º 11
0
        public ActionResult DoctorStatus(ReportPagingFilteringModel command, [Bind(Prefix = "ReportSearchModel")]ReportSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDoctors))
                return AccessDeniedView();

            if (command.PageSize <= 0) command.PageSize = _pageSize;
            if (command.PageNumber <= 0) command.PageNumber = 1;

            DoctorStatusReport model = new DoctorStatusReport();

            if (searchModel == null)
            {
                searchModel = new ReportSearchModel();
                searchModel.FromDate = new DateTime(DateTime.Now.Year, 1, 1);
                searchModel.ToDate = new DateTime(DateTime.Now.Year, 12, 31);
            }

            model.ReportSearchModel = searchModel;

            var query = from item in _dataContext.Doctors
                        group item by new
                        {
                            item.ClientDepartmentId,
                            item.DoctorGrade.DoctorGradeValue,
                        } into aGroup
                        select aGroup;

            IList<DoctorStatus> list = new List<DoctorStatus>();
            foreach (var item in query)
            {
                DoctorStatus details = new DoctorStatus();
                details.DepartmentName = item.First().ClientDepartment.ClientDepartmentName;
                details.DoctorGradeValue = item.First().DoctorGrade.DoctorGradeValue;
                details.NumberOfDoctors = item.Count();
                list.Add(details);
            }

            var data = new PagedList<DoctorStatus>(list, command.PageNumber - 1, int.MaxValue);

            model.Data = data;
            model.PagingFilteringContext.LoadPagedList(data);

            return View(model);
        }