/// <summary>
 /// Binds the data.
 /// </summary>
 private void BindData()
 {
     Entities = localSql.GetForwardEntities();
     Statuses = localSql.GetForwardStatuses();
     Statuses.Insert(0, new IntegerComboBoxModel {
         Name = "All", Value = 0
     });
 }
        private void LoadDataToUi()
        {
            IList <MessageSummaryModel> data = new List <MessageSummaryModel>
            {
                new MessageSummaryModel {
                    EntityId = (int)Entity.Product, EntityName = "Products", CompleteCount = 0, ProcessingCount = 0, ErrorCount = 0
                },
                new MessageSummaryModel {
                    EntityId = (int)Entity.SalesOrder, EntityName = "Sales Orders", CompleteCount = 0, ProcessingCount = 0, ErrorCount = 0
                },
                new MessageSummaryModel {
                    EntityId = (int)Entity.Customer, EntityName = "Customers", CompleteCount = 0, ProcessingCount = 0, ErrorCount = 0
                },
                new MessageSummaryModel {
                    EntityId = 0, EntityName = "Others", CompleteCount = 0, ProcessingCount = 0, ErrorCount = 0
                },
            };
            var searchData = new MessageSearchModel {
                CreatedFrom = DateTime.Today.AddDays(-FromDateSelected), CreatedTo = DateTime.Today.AddDays(1)
            };
            IList <MessageCountModel> databaseData = localSql.GetEcommerceMessageSummary(searchData);

            EntityCount = localSql.GetForwardEntities().Count;

            if (databaseData.Count > 0)
            {
                (from c1 in databaseData
                 join c2 in data on c1.EntityId equals c2.EntityId
                 select c1.StatusId == (int)MessageStatus.Complete ? c2.CompleteCount = c1.Count :
                                                                                        c1.StatusId == (int)MessageStatus.Error ? c2.ErrorCount = c1.Count : c2.ProcessingCount += c1.Count).ToArray();

                (from c1 in databaseData
                 from c2 in data
                 where c2.EntityId == 0 & c1.EntityId != (int)Entity.Customer & c1.EntityId != (int)Entity.SalesOrder & c1.EntityId != (int)Entity.Product
                 select c1.StatusId == (int)MessageStatus.Complete ? c2.CompleteCount = c1.Count :
                                                                                        c1.StatusId == (int)MessageStatus.Error ? c2.ErrorCount = c1.Count : c2.ProcessingCount += c1.Count).ToArray();
            }
            ReportData.Clear();
            ReportData.AddRange(data);
        }