private async Task SupplierTapped(LinCUser item)
        {
            try
            {
                AppSpinner.ShowLoading();

                var response = await _services.UserService.GetUserProducts(UserDetails.UserId,
                                                                           item.UserId, SelectedProductType.ProductTypeId);

                if (response.Data.Item1 != null && response.Data.Item1.Count > 0)
                {
                    ThreadingHelpers.InvokeOnMainThread(async() =>
                                                        await AppNavigationService.GoToAsync(nameof(ProductsPage).ToLower(),
                                                                                             (ProductsPageViewModel vm) =>
                    {
                        vm.UserDetails = App.UserDetails;
                        vm.Products    = response.Data.Item1;
                        vm.SupplierId  = item.UserId;
                    })
                                                        );
                }

                AppSpinner.HideLoading();
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
        public LoginPageViewModel(ILinCApiServices services)
        {
            _services       = services;
            LoginCommand    = new CustomDelegateTimerCommand(async() => await Login(), () => true);
            RegisterCommand = new CustomDelegateTimerCommand(() => Register(), () => true);
            CallCommand     = new CustomDelegateTimerCommand(() => CallCustomerCare(), () => true);

            UserDetails = new LinCUser();
        }
示例#3
0
        public async Task <ServiceResponse <List <Order> > > GetOrders(LinCUser user, int?orderId = null)
        {
            var headers = RequestHeaderCreator.GetWebApiClientHeader();

            GetOrderReq getOrdReq = new GetOrderReq();

            switch (user.UserTypeId)
            {
            case 2:     //LinCUserType.Consumer:
                getOrdReq.ConsumerId = user.UserId;
                getOrdReq.SearchType = "CONSUMER";
                break;

            case 1:    // LinCUserType.Supplier:
                getOrdReq.SupplierId = user.UserId;
                getOrdReq.SearchType = "SUPPLIER";
                break;

            case 3:    // LinCUserType.Volunteer:
                getOrdReq.VolunteerId = user.UserId;
                getOrdReq.SearchType  = "VOLUNTEER";
                break;

            default:
                break;
            }

            getOrdReq.OrderId = orderId;

            var response = await _restClient
                           .ExecuteAsync <string, GetOrderReq>(
                HttpVerb.POST,
                action : "/product/getOrder",
                paramMode : HttpParamMode.BODY,
                requestBody : getOrdReq,
                headers : headers,
                apiRoutePrefix : $"{AppSettings.ApiEndpoint}"
                );

            if (!response.IsOK() || string.IsNullOrEmpty(response.StringData))
            {
                return(new ServiceResponse <List <Order> >(ServiceStatus.Error, data: null, errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "Problem in saving product."));
            }

            var jSonResponse = response.StringData.Replace(@"\", string.Empty);

            if (jSonResponse.Contains("errorMessage"))
            {
                return(new ServiceResponse <List <Order> >(ServiceStatus.Error, data: null, errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "Problem in saving product."));
            }

            var ordersResponse = JsonConvert.DeserializeObject <GetOrderResponse>(jSonResponse);

            return(new ServiceResponse <List <Order> >(ServiceStatus.Success, data: ordersResponse.Orders));
        }
示例#4
0
        public async Task <ServiceResponse <UserReqBody> > Login(string userId, string pwd)
        {
            var      headers = RequestHeaderCreator.GetWebApiClientHeader();
            LinCUser newUser = new LinCUser()
            {
                Email = userId, UserSecret = pwd
            };
            var reqObject = new RequestInfo <UserReqBody>
            {
                Message = new RequestMessege <UserReqBody>
                {
                    //Header = RequestHeaderCreator.GetRequestHeader(deviceDensity, deviceType, newUser.CompanyCode, newUser.UserCode, newUser.UserId),
                    Body = new UserReqBody
                    {
                        UserInfo = newUser
                    }
                }
            };

            var response = await _restClient
                           .ExecuteAsync <string, RequestInfo <UserReqBody> >(
                HttpVerb.POST,
                action : "UserDetailsSave",
                paramMode : HttpParamMode.BODY,
                requestBody : reqObject,
                headers : headers,
                apiRoutePrefix : $"{AppSettings.ApiEndpoint}"
                );

            if (!response.IsOK() || string.IsNullOrEmpty(response.StringData))
            {
                return(new ServiceResponse <UserReqBody>(ServiceStatus.Error, data: null, errorMessage: "User data not saved."));
            }
            var jSonResponse = response.StringData.Substring(1, response.StringData.Length - 2);

            jSonResponse = jSonResponse.Replace(@"\", string.Empty);

            ResponseInfo <Error> errorResponse = JsonConvert.DeserializeObject <ResponseInfo <Error> >(jSonResponse);

            var UserResponse = JsonConvert.DeserializeObject <ResponseInfo <UserReqBody> >(jSonResponse);

            if (UserResponse.Message.Body.UserInfo.UserCode.Equals("Error:0000"))
            {
                return(new ServiceResponse <UserReqBody>(ServiceStatus.Error, data: null, message: "Error:0000", errorMessage: "User data not saved."));
            }

            return(new ServiceResponse <UserReqBody>(ServiceStatus.Success, data: UserResponse.Message.Body));
        }
示例#5
0
        public RegistrationPageViewModel(ILinCApiServices services)
        {
            _services = services;
            UserTypeSelectionCommand         = new CustomDelegateCommand <object>(userType => SectionVisibilityAction(userType), (userType) => true);
            UseLocationSelectionCommand      = new CustomDelegateCommand <object>(selectionType => UseLocationSelectionAction(selectionType), (selectionType) => true);
            UserRegistrationSelectionCommand = new CustomDelegateCommand <object>(selectionType => UseRegistrationSelectionAction(selectionType), (selectionType) => true);
            ServiceTypeSelectionCommand      = new CustomDelegateCommand <object>(selectionType => ServiceTypeSelectionAction(selectionType), (selectionType) => true);
            PickerCellCommand = new CustomDelegateTimerCommand <object>((item) => PickerTapped(item), item => true);

            UserDetails                = new LinCUser();
            UserDetails.UserTypeId     = 0;
            UserDetails.ProductTypeIds = new List <int>();
            IsOrgVisible               = true;

            NextButtonTappedCommand = new CustomDelegateTimerCommand(async() => await NextButtonTapped(), () => true);
        }
        public static List <LinCUser> ConvertSuppliersResponse(SuppliersResponse suppliersResponse)
        {
            List <LinCUser> suppliers = new List <LinCUser>();

            try
            {
                if (suppliersResponse != null && suppliersResponse.Suppliers.Count > 0)
                {
                    foreach (var item in suppliersResponse.Suppliers)
                    {
                        LinCUser supplier = new LinCUser();

                        supplier.UserId = item.UserId;
                        supplier.Email  = item.Email;

                        supplier.FirstName  = item.FisrtName;
                        supplier.FirstName  = item.FisrtName;
                        supplier.LastName   = item.LastName;
                        supplier.MiddleName = item.MiddleName;
                        supplier.Phone      = item.PhoneNumber;
                        supplier.Pin        = item.Pin;
                        supplier.Latitude   = item.Latitude;
                        supplier.Longitude  = item.Longitude;

                        supplier.AddressLine1 = item.Addr1;
                        supplier.AddressLine2 = item.Addr2;
                        supplier.FullAddress  = item.FullAddress;
                        supplier.StateName    = item.State;
                        supplier.CountryName  = item.Country;
                        supplier.Distance     = Math.Floor(item.Distance);

                        supplier.ProductTypeIds = item.ProductTypes.Select(l => l.ProductTypeMasterId).Distinct().ToList();

                        suppliers.Add(supplier);
                    }
                }
            }
            catch (Exception ex)
            {
            }


            return(suppliers);
        }
示例#7
0
        public async Task <ServiceResponse <LinCUser> > CreateUserAsync(string deviceDensity, string deviceType, LinCUser newUser)
        {
            var headers = RequestHeaderCreator.GetWebApiClientHeader();

            var response = await _restClient
                           .ExecuteAsync <string, LinCUser>(
                HttpVerb.POST,
                action : "/user/registration",
                paramMode : HttpParamMode.BODY,
                requestBody : newUser,

                headers : headers,
                apiRoutePrefix : $"{AppSettings.ApiEndpoint}"
                );

            if (!response.IsOK() || string.IsNullOrEmpty(response.StringData))
            {
                return(new ServiceResponse <LinCUser>(ServiceStatus.Error, data: null, errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "User data not saved."));
            }

            var jSonResponse = response.StringData.Replace(@"\", string.Empty);

            if (jSonResponse.Contains("errorMessage"))
            {
                return(new ServiceResponse <LinCUser>(ServiceStatus.Error, data: null, errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "User data not saved."));
            }

            var userResponse = JsonConvert.DeserializeObject <LinCUser>(jSonResponse);

            return(new ServiceResponse <LinCUser>(ServiceStatus.Success, data: userResponse, errorCode: LinCTrasactionStatus.Success.ToString()));
        }
示例#8
0
        public async Task <ServiceResponse <List <Order> > > SaveOrders(List <Product> ordersToAdd, LinCUser user, int?supplierId)
        {
            var headers = RequestHeaderCreator.GetWebApiClientHeader();

            List <OrderProductReq> ordsReq = new List <OrderProductReq>();

            foreach (var item in ordersToAdd)
            {
                OrderProductReq ordReq = new OrderProductReq();
                ordReq.ProductId                 = item.ProductId;
                ordReq.ProductDescription        = item.Description;
                ordReq.ProductName               = item.ProductName;
                ordReq.ProductRate               = item.Price;
                ordReq.QuantityOrdered           = item.Quantity;
                ordReq.TotalPrice                = item.Price;
                ordReq.UserProductInventoryTrxId = item.UsrProductInventoryTrxId;

                ordsReq.Add(ordReq);
            }

            SaveOrderReq saveOrdReq = new SaveOrderReq();

            switch (user.UserTypeId)
            {
            case 2:     //LinCUserType.Consumer:
                saveOrdReq.Consumer   = user.FullName;
                saveOrdReq.ConsumerId = user.UserId;
                saveOrdReq.SupplierId = supplierId;
                break;

            case 1:    // LinCUserType.Supplier:
                saveOrdReq.Supplier   = user.FullName;
                saveOrdReq.SupplierId = user.UserId;
                //saveOrdReq.SupplierId = supplierId;
                break;

            case 3:    // LinCUserType.Volunteer:
                saveOrdReq.Volunteer     = user.FullName;
                saveOrdReq.VolunteerId   = user.UserId;
                saveOrdReq.IsVolunteered = 1;
                saveOrdReq.SupplierId    = supplierId;
                break;

            default:
                break;
            }
            saveOrdReq.Products    = ordsReq;
            saveOrdReq.OrderTotal  = ordersToAdd.Count;
            saveOrdReq.OrderStatus = "ORDPLCD";

            var response = await _restClient
                           .ExecuteAsync <string, SaveOrderReq>(
                HttpVerb.POST,
                action : "/product/saveOrder",
                paramMode : HttpParamMode.BODY,
                requestBody : saveOrdReq,
                headers : headers,
                apiRoutePrefix : $"{AppSettings.ApiEndpoint}"
                );

            if (!response.IsOK() || string.IsNullOrEmpty(response.StringData))
            {
                return(new ServiceResponse <List <Order> >(ServiceStatus.Error, data: null, errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "Problem in saving product."));
            }

            var jSonResponse = response.StringData.Replace(@"\", string.Empty);

            if (jSonResponse.Contains("errorMessage") || jSonResponse.Contains("BUSINESS ERROR"))
            {
                return(new ServiceResponse <List <Order> >(ServiceStatus.Error, data: null, errorCode: LinCTrasactionStatus.Failure.ToString(), errorMessage: "Problem in saving product."));
            }
            var ordersResponse = await GetOrders(user);

            //var ordersResponse = JsonConvert.DeserializeObject<GetOrderResponse>(jSonResponse);

            //return new ServiceResponse<List<Order>>(ServiceStatus.Success, data: ordersResponse.Orders);
            return(new ServiceResponse <List <Order> >(ServiceStatus.Success, data: ordersResponse.Data));
        }