Example #1
0
 public DTO.SupportFormData GetSearchFilter(out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification {
         Type = Library.DTO.NotificationType.Success
     };
     DTO.SupportFormData data = new DTO.SupportFormData();
     data.SaleDTOs = new List <DTO.SaleDTO>();
     try
     {
         using (MIDeltaByClientOSRptEntities context = CreateContext())
         {
             data.SaleDTOs.Add(new DTO.SaleDTO {
                 UserID = -1, SaleUD = "GEN", EmployeeNM = "General"
             });
             data.SaleDTOs.AddRange(converter.DB2DTO_SaleDTO(context.SupportMng_AccountManager_View.Where(o => o.IsAccountManager).ToList()));
         }
     }
     catch (Exception ex)
     {
         notification.Type    = Library.DTO.NotificationType.Error;
         notification.Message = Library.Helper.GetInnerException(ex).Message;
     }
     return(data);
 }
Example #2
0
        public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFormData data = new DTO.SearchFormData();
            data.Data = new List <DTO.DeltaByClientDTO>();
            data.AccountManagerSummaryDTOs = new List <DTO.AccountManagerSummaryDTO>();
            totalRows = 0;

            string Season = null;
            int?   SaleID = null;
            int    UserID = 0;

            if (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString()))
            {
                Season = filters["Season"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("UserID") && filters["UserID"] != null && !string.IsNullOrEmpty(filters["UserID"].ToString()))
            {
                UserID = Convert.ToInt32(filters["UserID"].ToString());
            }
            if (!fwFactory.HasSpecialPermission(UserID, "ViewAllSalesData"))
            {
                SaleID = UserID;
            }
            else
            {
                if (filters.ContainsKey("SaleID") && filters["SaleID"] != null && !string.IsNullOrEmpty(filters["SaleID"].ToString()))
                {
                    SaleID = Convert.ToInt32(filters["SaleID"].ToString());
                }
                if (SaleID == -1)
                {
                    SaleID = null;
                }
            }

            //try to get data
            try
            {
                using (MIDeltaByClientOSRptEntities context = CreateContext())
                {
                    var        result          = context.MIDeltaByClientOSRpt_function_SearchData(Season, SaleID, orderBy, orderDirection).ToList();
                    List <int> existingSaleIDs = result.Select(r => r.SaleID.Value).ToList();
                    string     prevSeason      = Library.Helper.GetPreviousSeason(Season);
                    var        accData         = context.MIDeltaByClientOSRpt_AccountManagerSummary_View.Where(o => existingSaleIDs.Contains(o.SaleID.Value) && o.Season == prevSeason);
                    data.Data = converter.DB2DTO_DeltaByClient(result);
                    data.AccountManagerSummaryDTOs = converter.DB2DTO_AccountManagerSummaryDTO(accData.ToList());
                    totalRows = result.Count();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }