Beispiel #1
0
        public async Task <ObservableCollection <OfferData> > PopulateOfferData()
        {
            try
            {
                var app = App.Current as App;
                Dictionary <string, object> payload = new Dictionary <string, object>();
                payload.Add("merchant_id", app.Merchantid);
                payload.Add("phone_number", app.UserPhoneNumber);
                payload.Add("access_key", app.SecurityAccessKey);
                OfferResponse robject = await this.Post <OfferResponse>(this.getAuthUrl("getOfferDetails"), payload, null);

                ObservableCollection <OfferData> OfferList = new ObservableCollection <OfferData>();
                var c = 0;
                foreach (var item in robject.data)
                {
                    OfferList.Add(item);
                }
                Log.Debug("[CategoryDataService]", "Retrieved categories " + robject.data.Count);
                return(OfferList);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Beispiel #2
0
        private void SaveOfferAPI()
        {
            OfferResponse    offerResponse = new OfferResponse();
            SIMSResponseData responseStatus;

            offerResponse.vehicleId  = AppDelegate.appDelegate.vehicleID;
            offerResponse.storeId    = AppDelegate.appDelegate.storeId;
            offerResponse.invtrId    = AppDelegate.appDelegate.invtrId;
            offerResponse.ProspectId = AppDelegate.appDelegate.prospectId;
            offerResponse.TrimId     = AppDelegate.appDelegate.trimId;
            offerResponse.UserName   = "******";

            string DeviceToken = AppDelegate.appDelegate.AppleDeviceToken;

            responseStatus = ServiceFactory.ServiceOffer.getWebServiceHandle().SaveOffer(AppDelegate.appDelegate.vehicleID, AppDelegate.appDelegate.storeId, AppDelegate.appDelegate.invtrId, "ExterAppraisalApp", AppDelegate.appDelegate.prospectId, AppDelegate.appDelegate.trimId);
        }
Beispiel #3
0
 public async Task <int> UpdateOffer(int id, OfferResponse offers)
 {
     Data.Models.Oferty off = new Data.Models.Oferty
     {
         OpisOferty = offers.OpisOferty
     };
     try
     {
         await _managementRep.UpdateOffer(id, off);
     }
     catch (Exception e)
     {
         return(-1);
     }
     return(id);
 }
Beispiel #4
0
        // Przesyła odpowiedź administratora do oferty sprzedaży książki.
        public StatusResult <SendOfferResponseStatus> SendResponseToOffer(OfferResponseDto response)
        {
            var offer = context.Offers
                        .Include(x => x.OfferResponse)
                        .SingleOrDefault(x => x.Id == response.OfferId);

            if (offer == null)
            {
                return(new StatusResult <SendOfferResponseStatus>
                {
                    Status = SendOfferResponseStatus.NoOffer
                });
            }

            if (offer.OfferResponse != null)
            {
                return(new StatusResult <SendOfferResponseStatus>
                {
                    Status = SendOfferResponseStatus.OfferHasResponse
                });
            }

            var newOfferStatusId = context.OfferStatuses.Single(x => x.Id == 2).Id;

            offer.OfferStatusId = newOfferStatusId;

            var toAdd = new OfferResponse
            {
                ResponseDate          = System.DateTime.Now,
                ResponseText          = response.ResponseText,
                ProposedPrice         = response.ProposedPrice,
                OfferResponseStatusId = response.OfferResponseStatusId,
            };

            context.OfferResponses.Add(toAdd);
            offer.OfferResponseId = toAdd.Id;

            context.SaveChanges();

            return(new StatusResult <SendOfferResponseStatus>
            {
                Status = SendOfferResponseStatus.Ok
            });
        }
        public async Task GetAllAsyncWhenNoOffersReturnsEmptyCollection()
        {
            //Arrange
            var mockOfferRepository = GetDefaultIOfferRepositoryInstance();
            var mockUnitOfWork      = GetDefaultIUnitOfWorkInstance();
            var offerId             = 200;

            mockOfferRepository.Setup(r => r.FindById(offerId))
            .Returns(Task.FromResult <Offer>(null));

            var service = new OfferService(mockOfferRepository.Object, mockUnitOfWork.Object);
            //Act
            OfferResponse result = await service.GetByIdAsync(offerId);

            var message = result.Message;

            //Assert
            message.Should().Be("Offer not found");
        }
Beispiel #6
0
        public async Task <IActionResult> Create([FromBody] CreateOfferRequest offer)
        {
            var Offers = new Offers
            {
                ArabicDesc  = offer.ArabicDesc,
                EnglishDesc = offer.EnglishDesc,
                offerPrice  = offer.offerPrice,
                ImgUrl      = offer.ImgUrl,
                ProductId   = offer.ProductId,
                status      = offer.status
            };

            var status = await _OffersService.CreateOffersAsync(Offers);

            if (status == -1)
            {
                return(Conflict(new ErrorResponse
                {
                    message = "Dublicate Entry",
                    status = Conflict().StatusCode
                }));
            }

            if (status == 1)
            {
                await _productService.UpdateProductSalePriceAsync(offer.ProductId, offer.offerPrice);

                var response = new OfferResponse {
                    Id = Offers.Id
                };
                return(Ok(response));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }
Beispiel #7
0
        public void Handle(IOffer <MultiLineTextList, IViewModelBase> message)
        {
            History.Events.ThinkingAboutTargetEvent.Publish(System.Guid.Empty);
            DisableNavigationRequestedEventMessage.Publish();
            try
            {
                //WE ONLY CARE ABOUT OFFERS IN THE STUDY CATEGORY
                if (message.Category != StudyResources.CategoryStudy)
                {
                    return;
                }
                //WE DON'T CARE ABOUT MESSAGES WE PUBLISH OURSELVES
                if (message.PublisherId == Id)
                {
                    return;
                }

                //WE ONLY CARE ABOUT OFFERS PERTAINING TO OUR FUTURE AND PAST OPPORTUNITIES
                var resultsFuture = (from opportunity in FutureOpportunities
                                     where opportunity.Id == message.Opportunity.Id
                                     select opportunity);
                if (resultsFuture.Count() != 1)
                {
                    //NO OPEN FUTURE OPPORTUNITIES, NOW CHECK OUR PAST
                    var resultsOther = (from opportunity in PastOpportunities
                                        where opportunity.Id == message.Opportunity.Id
                                        select opportunity).Concat
                                           (from opportunity in CurrentOpportunities
                                           where opportunity.Id == message.Opportunity.Id
                                           select opportunity);

                    if (resultsOther.Count() >= 1)
                    {
                        //WE HAVE THIS IN THE PAST OR CURRENT, SO THIS OPPORTUNITY HAS ALREADY BEEN/IS ALREADY BEING
                        //HANDLED, SO WE WILL DENY THIS OFFER
                        var denyResponse      = OfferResources.OfferResponseDeny;
                        var denyOfferResponse = new OfferResponse <MultiLineTextList, IViewModelBase>(message, Id, this, denyResponse,
                                                                                                      StudyResources.CategoryStudy, null);

                        //PUBLISH DENY OFFER RESPONSE
                        Exchange.Ton.Publish(denyOfferResponse);
                        return;
                    }
                    else
                    {
                        //NOT IN FUTURE OR PAST, SO DOESN'T PERTAIN TO US
                        return;
                    }
                }

                //THIS PERTAINS TO A FUTURE OPPORTUNITY, SO WE WILL EXAMINE THIS FURTHER
                //FOR NOW, THIS MEANS THAT WHATEVER THE OFFER IS, WE WILL ACCEPT IT.
                //IN THE POSSIBLY NEAR FUTURE, WE WILL HAVE TO CONSIDER IF SOMEONE ELSE
                //HAS SOMETHING MORE IMPORTANT TO DO
                var pertinentOpportunity = resultsFuture.First();

                var acceptResponse      = OfferResources.OfferResponseAccept;
                var acceptOfferResponse = new OfferResponse <MultiLineTextList, IViewModelBase>(message, Id, this, acceptResponse,
                                                                                                StudyResources.CategoryStudy, null);

                //BEFORE PUBLISHING, MOVE OPPORTUNITY TO CURRENT OPPORTUNITIES.
                FutureOpportunities.Remove(pertinentOpportunity);
                CurrentOpportunities.Add(pertinentOpportunity);

                //PUBLISH ACCEPT OFFER RESPONSE
                Exchange.Ton.Publish(acceptOfferResponse);
                GoInProgress = false;
            }
            finally
            {
                EnableNavigationRequestedEventMessage.Publish();
            }
        }
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();
                hash = hash * 59 + RotationListSortOrder.GetHashCode();

                if (Equipment != null)
                {
                    hash = hash * 59 + Equipment.GetHashCode();
                }
                if (RentalAgreement != null)
                {
                    hash = hash * 59 + RentalAgreement.GetHashCode();
                }

                if (IsForceHire != null)
                {
                    hash = hash * 59 + IsForceHire.GetHashCode();
                }

                if (WasAsked != null)
                {
                    hash = hash * 59 + WasAsked.GetHashCode();
                }

                if (AskedDateTime != null)
                {
                    hash = hash * 59 + AskedDateTime.GetHashCode();
                }

                if (OfferResponse != null)
                {
                    hash = hash * 59 + OfferResponse.GetHashCode();
                }

                if (OfferRefusalReason != null)
                {
                    hash = hash * 59 + OfferRefusalReason.GetHashCode();
                }

                if (OfferResponseDatetime != null)
                {
                    hash = hash * 59 + OfferResponseDatetime.GetHashCode();
                }

                if (OfferResponseNote != null)
                {
                    hash = hash * 59 + OfferResponseNote.GetHashCode();
                }

                if (Note != null)
                {
                    hash = hash * 59 + Note.GetHashCode();
                }

                return(hash);
            }
        }
        /// <summary>
        /// Returns true if RentalRequestRotationList instances are equal
        /// </summary>
        /// <param name="other">Instance of RentalRequestRotationList to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RentalRequestRotationList other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     RotationListSortOrder == other.RotationListSortOrder ||
                     RotationListSortOrder.Equals(other.RotationListSortOrder)
                 ) &&
                 (
                     Equipment == other.Equipment ||
                     Equipment != null &&
                     Equipment.Equals(other.Equipment)
                 ) &&
                 (
                     RentalAgreement == other.RentalAgreement ||
                     RentalAgreement != null &&
                     RentalAgreement.Equals(other.RentalAgreement)
                 ) &&
                 (
                     IsForceHire == other.IsForceHire ||
                     IsForceHire != null &&
                     IsForceHire.Equals(other.IsForceHire)
                 ) &&
                 (
                     WasAsked == other.WasAsked ||
                     WasAsked != null &&
                     WasAsked.Equals(other.WasAsked)
                 ) &&
                 (
                     AskedDateTime == other.AskedDateTime ||
                     AskedDateTime != null &&
                     AskedDateTime.Equals(other.AskedDateTime)
                 ) &&
                 (
                     OfferResponse == other.OfferResponse ||
                     OfferResponse != null &&
                     OfferResponse.Equals(other.OfferResponse)
                 ) &&
                 (
                     OfferRefusalReason == other.OfferRefusalReason ||
                     OfferRefusalReason != null &&
                     OfferRefusalReason.Equals(other.OfferRefusalReason)
                 ) &&
                 (
                     OfferResponseDatetime == other.OfferResponseDatetime ||
                     OfferResponseDatetime != null &&
                     OfferResponseDatetime.Equals(other.OfferResponseDatetime)
                 ) &&
                 (
                     OfferResponseNote == other.OfferResponseNote ||
                     OfferResponseNote != null &&
                     OfferResponseNote.Equals(other.OfferResponseNote)
                 ) &&
                 (
                     Note == other.Note ||
                     Note != null &&
                     Note.Equals(other.Note)
                 ));
        }
Beispiel #10
0
        public async Task <ActionResult> Put(int id, [FromBody] OfferResponse offers)
        {
            var ret = await _magagementServ.UpdateOffer(id, offers);

            return(Ok(ret));
        }