Example #1
0
        public int CheckConnection(CheckConnectDto checkConnectDto)
        {
            var courier = _courierRepository.FirstOrDefault(o => o.Id == checkConnectDto.Id);

            if (courier != null)
            {
                if (courier.Imei == checkConnectDto.Imei)
                {
                    if (courier.Status == (int)StatusCourier.Offline)
                    {
                        //add system event
                        _systemEventRepository.Add(EventMessage.CourierOnline, new Dictionary <EventMessageParam, string> {
                            { EventMessageParam.Courier, courier.User.FullName }
                        });
                    }
                    var currentReq = _requestRepository.GetById(checkConnectDto.CurrentRequest);

                    if (currentReq != null && currentReq.Status == (int)StatusRequest.Started)
                    {
                        courier.CurrentReq = checkConnectDto.CurrentRequest;
                    }

                    courier.Status          = (int)StatusCourier.Online;
                    courier.CurrentVelocity = checkConnectDto.CurrentVelocity;
                    courier.CurrentLng      = checkConnectDto.CurrentLng;
                    courier.CurrentLat      = checkConnectDto.CurrentLat;
                    _courierRepository.Update(courier);
                    _courierRepository.Commit();
                    return(1);
                }
                return(2);
            }
            return(0);
        }
Example #2
0
        public IHttpActionResult CheckConnection(CheckConnectDto checkConnectDto)
        {
            var franchisee     = _franchiseeConfigurationService.FirstOrDefault();
            var franchiseeData = new FranchisseNameAndLicenseDto()
            {
                LicenseKey     = franchisee.LicenseKey,
                FranchiseeName = franchisee.Name
            };

            var objTokenStore = _webApiConsumeUserService.GetToken(franchiseeData);

            if (objTokenStore != null)
            {
                int checkConnectValue = _courierService.CheckConnection(checkConnectDto);
                return(Ok(new DtoBase {
                    Id = checkConnectValue
                }));
            }

            return(Ok(new DtoBase {
                Id = 10
            }));
        }