public static List <StoreModel> GetQueryToSearchStore(CallCenterEntities dbEntities, string franchiseCode, AddressInfoModel model, out int franchiseId)
        {
            franchiseId = dbEntities.Franchise.Where(e => e.IsObsolete == false && e.Code == franchiseCode).Select(e => e.FranchiseId).Single();

            var id    = franchiseId;
            var query = dbEntities.StoreAddressDistribution.Where(e => e.FranchiseStore.FranchiseId == id);

            if (SettingsData.Store.ByCountry)
            {
                query = query.Where(e => e.CountryId == model.Country.IdKey);
            }
            if (SettingsData.Store.ByRegionA)
            {
                query = query.Where(e => e.RegionArId == model.RegionA.IdKey);
            }
            if (SettingsData.Store.ByRegionB)
            {
                query = query.Where(e => e.RegionBrId == model.RegionB.IdKey);
            }
            if (SettingsData.Store.ByRegionC)
            {
                query = query.Where(e => e.RegionCrId == model.RegionC.IdKey);
            }
            if (SettingsData.Store.ByRegionD)
            {
                query = query.Where(e => e.RegionDrId == model.RegionD.IdKey);
            }
            if (SettingsData.Store.ByZipCode)
            {
                query = query.Where(e => e.ZipCodeId == model.ZipCode.IdKey);
            }

            return(query.OrderByDescending(e => e.Importance).Select(e =>
                                                                     new StoreModel
            {
                Key = e.FranchiseStoreId.ToString(),
                IdKey = e.FranchiseStoreId,
                Value = e.FranchiseStore.Name,
                MainAddress = e.FranchiseStore.Address.MainAddress,
                LstPhones = e.FranchiseStore.FranchisePhone.Select(i => i.Phone).ToList(),
                WsAddress = e.FranchiseStore.WsAddress
            }).ToList());
        }
        protected virtual void Dispose(bool disposing)
        {
            try
            {
                if (!disposing)
                {
                    return;
                }

                if (DbConn != null)
                {
                    DbConn.Dispose();
                }
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
            }
            finally
            {
                DbConn = null;
            }
        }
Beispiel #3
0
 public ActionResult ZipCodes(string code)
 {
     try
     {
         using (var repository = new CallCenterEntities())
         {
             var data = FactoryAddress.GetQueryToExecByZipCode(repository, code, true).ToList();
             return(Json(new ResponseMessageModel
             {
                 HasError = false,
                 Data = data,
             }));
         }
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(Json(new ResponseMessageModel
         {
             HasError = false,
             Message = "Se presentó un problema al momento de consultar la información",
         }));
     }
 }
Beispiel #4
0
 public AccountRepository(CallCenterEntities db)
     : base(db)
 {
 }
Beispiel #5
0
 public UserRepository(CallCenterEntities dbConn)
     : base(dbConn)
 {
 }
 protected BaseRepository(CallCenterEntities dbConn)
 {
     DbConn = dbConn;
 }
 public MailManagement()
 {
     _entities = new CallCenterEntities();
 }
 public TelefonManagement()
 {
     _entities = new CallCenterEntities();
 }
Beispiel #9
0
 public StoreSettingService(CallCenterEntities callCenter)
     : this(new StoreRepository(callCenter), new AddressRepository(callCenter))
 {
 }
 protected BaseOneRepository(CallCenterEntities dbEntities)
 {
     DbEntities = dbEntities;
 }
 protected BaseOneRepository()
 {
     DbEntities = new CallCenterEntities();
 }
Beispiel #12
0
 public MusteriManagement()
 {
     _entities = new CallCenterEntities();
 }
Beispiel #13
0
 public OrderRepository(CallCenterEntities dbEntities)
     : base(dbEntities)
 {
 }
 public AdresManagement()
 {
     _entities = new CallCenterEntities();
 }
        public static IQueryable <AddressResponseSearch> GetQueryToExecByZipCode(CallCenterEntities dbEntities, String zipCode, bool startWith = false)
        {
            string regionChild = GetRegionChildByZipCode();


            switch (regionChild)
            {
            case AddressConstants.REGION_A:
            {
                System.Linq.Expressions.Expression <Func <RegionA, bool> > linqExp;
                if (startWith)
                {
                    linqExp = e => e.ZipCode.Code.StartsWith(zipCode);
                }
                else
                {
                    linqExp = e => e.ZipCode.Code == zipCode;
                }

                return(dbEntities.RegionA.Where(linqExp).Select(e => new AddressResponseSearch
                    {
                        Country = new ListItemModel {
                            IdKey = e.CountryId, Value = e.Country.Name
                        },
                        RegionA = new ListItemModel {
                            IdKey = e.RegionId, Value = e.Name
                        },
                        ZipCode = new ListItemModel {
                            IdKey = e.ZipCodeId, Value = e.ZipCode.Code
                        }
                    }).Take(50));
            }

            case AddressConstants.REGION_B:
            {
                System.Linq.Expressions.Expression <Func <RegionB, bool> > linqExp;
                if (startWith)
                {
                    linqExp = e => e.ZipCode.Code.StartsWith(zipCode);
                }
                else
                {
                    linqExp = e => e.ZipCode.Code == zipCode;
                }

                return(dbEntities.RegionB.Where(linqExp).Select(e => new AddressResponseSearch
                    {
                        Country = new ListItemModel {
                            IdKey = e.CountryId, Value = e.Country.Name
                        },
                        RegionA = new ListItemModel {
                            IdKey = e.RegionArId, Value = e.RegionA.Name
                        },
                        RegionB = new ListItemModel {
                            IdKey = e.RegionId, Value = e.Name
                        },
                        ZipCode = new ListItemModel {
                            IdKey = e.ZipCodeId, Value = e.ZipCode.Code
                        }
                    }).Take(50));
            }

            case AddressConstants.REGION_C:
            {
                System.Linq.Expressions.Expression <Func <RegionC, bool> > linqExp;
                if (startWith)
                {
                    linqExp = e => e.ZipCode.Code.StartsWith(zipCode);
                }
                else
                {
                    linqExp = e => e.ZipCode.Code == zipCode;
                }

                return(dbEntities.RegionC.Where(linqExp).Select(e => new AddressResponseSearch
                    {
                        Country = new ListItemModel {
                            IdKey = e.CountryId, Value = e.Country.Name
                        },
                        RegionA = new ListItemModel {
                            IdKey = e.RegionArId, Value = e.RegionA.Name
                        },
                        RegionB = new ListItemModel {
                            IdKey = e.RegionBrId, Value = e.RegionB.Name
                        },
                        RegionC = new ListItemModel {
                            IdKey = e.RegionId, Value = e.Name
                        },
                        ZipCode = new ListItemModel {
                            IdKey = e.ZipCodeId, Value = e.ZipCode.Code
                        }
                    }).Take(50));
            }

            case AddressConstants.REGION_D:
            {
                System.Linq.Expressions.Expression <Func <RegionD, bool> > linqExp;
                if (startWith)
                {
                    linqExp = e => e.ZipCode.Code.StartsWith(zipCode);
                }
                else
                {
                    linqExp = e => e.ZipCode.Code == zipCode;
                }

                return(dbEntities.RegionD.Where(linqExp).Select(e => new AddressResponseSearch
                    {
                        Country = new ListItemModel {
                            IdKey = e.CountryId, Value = e.Country.Name
                        },
                        RegionA = new ListItemModel {
                            IdKey = e.RegionArId, Value = e.RegionA.Name
                        },
                        RegionB = new ListItemModel {
                            IdKey = e.RegionBrId, Value = e.RegionB.Name
                        },
                        RegionC = new ListItemModel {
                            IdKey = e.RegionCrId, Value = e.RegionC.Name
                        },
                        RegionD = new ListItemModel {
                            IdKey = e.RegionId, Value = e.Name
                        },
                        ZipCode = new ListItemModel {
                            IdKey = e.ZipCodeId, Value = e.ZipCode.Code
                        }
                    }).Take(50));
            }
            }

            throw new ArgumentNullException(String.Empty + "No está correctamente configurada la jerarquía de direcciones");
        }
Beispiel #16
0
 public static string GetIdByUsername(string username, CallCenterEntities dbEntities)
 {
     return(dbEntities.AspNetUsers.Where(e => e.UserName.Trim().ToLower() == username.Trim().ToLower())
            .Select(e => e.Id).Single());
 }
Beispiel #17
0
 public ReportRepository(CallCenterEntities dbEntities)
     : base(dbEntities)
 {
 }
Beispiel #18
0
 public FranchiseRepository(CallCenterEntities db)
     : base(db)
 {
 }
 public GenericRepository(CallCenterEntities dbConnP)
     : base(dbConnP)
 {
     _dbSet = DbConn.Set(typeof(TEntity));
 }
 public AddressRepository(CallCenterEntities callCenter)
     : base(callCenter)
 {
 }
 protected BaseRepository()
 {
     DbConn = new CallCenterEntities();
 }
 public StoreRepository(CallCenterEntities callCenter)
     : base(callCenter)
 {
 }