示例#1
0
        public StateListModel GetAllStatesByCountry(StateListModel state)
        {
            StateListModel stateListModel = new StateListModel();

            try
            {
                stateListModel.TableState = null;
                var StateList = this.context?.TableState.Where(x => x.CountryId == state.CountryId).ToList();
                if (StateList.Count > 0)
                {
                    stateListModel.TableState = StateList;
                }
                stateListModel._tenantName = state._tenantName;
                stateListModel._token      = state._token;
                stateListModel._failure    = false;
            }
            catch (Exception es)
            {
                stateListModel._message    = es.Message;
                stateListModel._failure    = true;
                stateListModel._tenantName = state._tenantName;
                stateListModel._token      = state._token;
            }
            return(stateListModel);
        }
        public IHttpActionResult GetListOfStates(string country)
        {
            var result = new StateListModel();

            switch (country)
            {
            case "US":
                result.States = LocationCodes.States
                                .Select(s => new StateItem()
                {
                    Id = s.Value, Name = s.Key
                })
                                .ToArray();
                break;

            case "CA":
                result.States = LocationCodes.Provinces
                                .Select(p => new StateItem()
                {
                    Id = p.Value, Name = p.Key
                })
                                .ToArray();
                break;

            default:
                result.States = new StateItem[0];
                break;
            }

            return(Ok(result));
        }
        public bool UpdateStateList(StateViewModel stateViewModel)
        {
            StateListModel state = new StateListModel
            {
                StateCode   = stateViewModel.StateCode,
                State       = stateViewModel.StateCode,
                CountryCode = stateViewModel.StateCode
            };

            return(_manageCityStateRepository.UpdateStateList(stateViewModel));
        }
示例#4
0
        public ActionResult <StateListModel> GetAllStatesByCountry(StateListModel state)
        {
            StateListModel stateListModel = new StateListModel();

            try
            {
                stateListModel = _commonService.GetAllStatesByCountry(state);
            }
            catch (Exception es)
            {
                stateListModel._failure = true;
                stateListModel._message = es.Message;
            }
            return(stateListModel);
        }
        public bool InsertStateList(StateViewModel stateViewModel)
        {
            // string statecode = stateViewModel.StateCode;
            //if (usp_CheckIfStateAlreadyExist(Convert.ToString(statecode)) == true)
            //{
            //    throw new UserAlreadyExists("State code already exist");
            //}
            StateListModel state = new StateListModel
            {
                StateCode   = stateViewModel.StateCode,
                State       = stateViewModel.StateCode,
                CountryCode = stateViewModel.StateCode
            };

            return(_manageCityStateRepository.InsertStateList(stateViewModel));
        }
示例#6
0
        public StateListModel GetAllStatesByCountry(StateListModel state)
        {
            StateListModel stateListModel = new StateListModel();
            if (TokenManager.CheckToken(state._tenantName, state._token))
            {
                stateListModel = this.commonRepository.GetAllStatesByCountry(state);
                return stateListModel;
            }
            else
            {
                stateListModel._failure = true;
                stateListModel._message = TOKENINVALID;
                return stateListModel;
            }

        }