コード例 #1
0
        public async void Handle(DataMessage dataMessage)
        {
            switch (dataMessage.Message)
            {
            case DataMessages.USER:
                switch (_userService.User.UserType)
                {
                case UserType.PERSON:
                    // COMMENT: Profile and Logout buttons are defined in the View. They are 'static' elements visible in all cases.
                    MenuItems.AddRange(new BindableCollection <CustomMenuItem>
                    {
                        new CustomMenuItem {
                            Name = "My vehicles", OnClick = GoToMyVehicles
                        },
                        new CustomMenuItem {
                            Name = "Market", OnClick = GoToMarket
                        },
                    });
                    PersonUserModel personUser = await _personUserService.Get(_userService.User.Username);

                    _personUserService.PersonUser      = personUser;
                    _personUserService.PersonUser.User = _userService.User;
                    if (personUser.PersonType == PersonType.POLICE)
                    {
                        MenuItems.Insert(2, new CustomMenuItem {
                            Name = "Report accident", OnClick = GoToReportAccident
                        });
                    }
                    break;

                case UserType.SERVICE:
                    MenuItems.AddRange(new BindableCollection <CustomMenuItem>
                    {
                        new CustomMenuItem {
                            Name = "Add service", OnClick = GoToAddService
                        },
                        new CustomMenuItem {
                            Name = "My services", OnClick = GoToMyServices
                        },
                    });
                    ServiceUserModel serviceUser = await _serviceUserService.Get(_userService.User.Username);

                    _serviceUserService.ServiceUser      = serviceUser;
                    _serviceUserService.ServiceUser.User = _userService.User;
                    break;

                default:
                    break;
                }
                // COMMENT: to avoid unsafe async reach to context from both this and MyVehiclesViewModel
                _eventAggregator.PublishOnUIThread(new DataMessage(DataMessages.HEADER_LOADED));
                break;

            default:
                break;
            }
        }
コード例 #2
0
        /// <summary>GetAllClientsDetail
        /// <CreatedBy>Bhushan Dod</CreatedBy>
        /// <CreatedOn>12-Feb-2015</CreatedOn>
        /// <CreatedFor>To get the Client details for android</CreatedFor>
        /// </summary>
        /// <returns>lstClients</returns>
        public ServiceResponseModel <List <ServiceUserModel> > GetAllClientList(ServiceUserModel objUserModel)
        {
            ObjUserRepository = new UserRepository();
            ServiceResponseModel <List <ServiceUserModel> > lstClients = new ServiceResponseModel <List <ServiceUserModel> >();

            try
            {
                if (objUserModel.ServiceAuthKey != null && objUserModel.UserId != null)
                {
                    var authuser = ObjUserRepository.GetSingleOrDefault(x => x.ServiceAuthKey == objUserModel.ServiceAuthKey && x.IsDeleted == false);

                    if (authuser != null && authuser.UserId > 0)
                    {
                        var result = ObjUserRepository.GetAllClientsDetail();
                        if (result != null || result.Count > 0)
                        {
                            lstClients.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture);
                            lstClients.Data     = result;
                            lstClients.Message  = CommonMessage.Successful();
                        }
                        else
                        {
                            lstClients.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                            lstClients.Message  = CommonMessage.WrongParameterMessage();
                        }
                    }
                    else
                    {
                        lstClients.Response = Convert.ToInt32(ServiceResponse.InvalidSessionResponse, CultureInfo.CurrentCulture);
                        lstClients.Message  = CommonMessage.InvalidUser();
                    }
                }
                else
                {
                    lstClients.Response = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                    lstClients.Message  = CommonMessage.WrongParameterMessage();
                }
                return(lstClients);
            }
            catch (Exception)
            { throw; }
        }