Пример #1
0
        public async Task <AuthenticationResponse> Authenticate(string email, string password)
        {
            var authRequest = new AuthenticationRequest
            {
                username   = email,
                Password   = password,
                grant_type = "password"
            };

            var response = await WebServiceClientBase.PostLogin(Constants.AuthenticationUri, authRequest);

            return(response);
        }
        public async Task <ObservationChangeResponse> ObservationChangeUpdate(string description, int observationId, int observation_change_id, string email)
        {
            var request = new ObservationChangeRequest
            {
                description           = description,
                user_email            = email,
                observation_id        = observationId,
                observation_change_id = observation_change_id
            };
            var response = await WebServiceClientBase.Post <ObservationChangeRequest, ObservationChangeResponse>(Constants.OperationChangeUpdateUri, request, true);

            return(response);
        }
        public async Task <ObservationCommentResponse> ObservationCommentUpdate(string comment, int observationId, int observation_comment_id, string email)
        {
            var request = new ObservationCommentRequest
            {
                comment                = comment,
                user_email             = email,
                observation_id         = observationId,
                observation_comment_id = observation_comment_id
            };
            var response = await WebServiceClientBase.Post <ObservationCommentRequest, ObservationCommentResponse>(Constants.OperationCommentUpdateUri, request, true);

            return(response);
        }
        public async Task <GetAllDataResponse> GetAllData(string email, int languageId)
        {
            var request = new GetAllDataRequest
            {
                email      = email,
                languageId = languageId
            };
            //var response = await WebServiceClientBase.Get<GetAllDataRequest, GetAllDataResponse>(Constants.GetAllDataUri, request, true);

            //return response;

            var response = await WebServiceClientBase.Get <GetAllDataResponse>(Constants.GetAllDataUri + "?email=" + email + "&languageId=" + languageId, true);

            return(response);
        }
        public async Task <ObservationUpdateResponse> ObservationUpdate(string email, int observationId, int indicatorId, int siteId, DateTime begin, DateTime end)
        {
            var request = new ObservationUpdateRequest
            {
                user_email     = email,
                observation_id = observationId,
                indicator_id   = indicatorId,
                site_id        = siteId,
                begin_date     = begin,
                end_date       = end
            };
            var response = await WebServiceClientBase.Post <ObservationUpdateRequest, ObservationUpdateResponse>(Constants.OperationUpdateUri, request, true);

            return(response);
        }
        public async Task <ObservationAttachmentResponse> ObservationAttachmentUpdate(byte[] bytes, string attachment, string attachment_file_name, int observationId, int observation_attachment_id, string email)
        {
            var request = new ObservationAttachmentRequest
            {
                attachment                = attachment,
                attachment_file_name      = attachment_file_name,
                observation_attachment_id = observation_attachment_id,
                observation_id            = observationId,
                user_email                = email,
                FileStream                = new MemoryStream(bytes)
            };
            var response = await WebServiceClientBase.PostAttachment(Constants.OperationAttachmentUpdateUri, request, true);

            //var response = await WebServiceClientBase.PostAttachment<ObservationAttachmentRequest, ObservationAttachmentResponse>(Constants.OperationAttachmentUpdateUri, request, true);
            return(response);
        }
Пример #7
0
        public async Task <RateCardResponse> GetRateCards()
        {
            var response = await WebServiceClientBase.Get <RateCardResponse>(Constants.RateCardUri, true);

            if (response != null && !response.ErrorStatusCode.IsErrorCode())
            {
                //Need to loop through returned rate cards and create RateCardLocals
                response.RateCardsLocal = new List <RateCardLocal>();

                foreach (RateCard card in response.RateCards)
                {
                    RateCardLocal local = new RateCardLocal();
                    local.AdvancePayments          = card.AdvancePayments;
                    local.AvailablePoints          = card.AvailablePoints;
                    local.EquipmentType            = card.EquipmentType;
                    local.EquipmentTypeDescription = card.EquipmentTypeDescription;
                    local.MaintenanceTypes         = card.MaintenanceTypes;
                    local.PurchaseOptions          = new List <PurchaseOption>();
                    foreach (string option in card.PurchaseOptions)
                    {
                        local.PurchaseOptions.Add(new PurchaseOption {
                            PurchaseOptionDesc = option
                        });
                    }
                    local.RateCardID    = card.RateCardID;
                    local.RateCardName  = card.RateCardName;
                    local.MaximumAmount = card.MaximumAmount;
                    local.MinimumAmount = card.MinimumAmount;
                    local.Terms         = new List <TermItem> ();
                    foreach (int t in card.Terms)
                    {
                        local.Terms.Add(new TermItem {
                            Term = t
                        });
                    }

                    response.RateCardsLocal.Add(local);
                }
            }

            return(response);
        }
        public async Task <ObservationEntryUpdateResponse> ObservationEntryUpdate(int observationEntryId, int observationId, int indicatorAgeRange, string indicatorGender,
                                                                                  int numerator, int denominator, double count, double rate, bool yesNo, string email)
        {
            var request = new ObservationEntryUpdateRequest
            {
                count                  = (int)count,
                denominator            = denominator,
                indicator_age_range_id = indicatorAgeRange,
                indicator_gender       = indicatorGender,
                numerator              = numerator,
                observation_entry_id   = observationEntryId,
                observation_id         = observationId,
                rate       = rate,
                user_email = email,
                yes_no     = yesNo
            };
            var response = await WebServiceClientBase.Post <ObservationEntryUpdateRequest, ObservationEntryUpdateResponse>(Constants.OperationEntryUpdateUri, request, true);

            return(response);
        }
Пример #9
0
        public async Task <SubmitCreditAppResponse> SubmitCreditApp(CreditApp creditApp)
        {
            //=== test data ===
            //var submitCreditAppRequest = new SubmitCreditAppRequest
            //{
            //    Application = new CreditAppMetaData
            //    {
            //        EnteredBy = "",
            //        ApplicationType = "New",
            //        ApplicationFormat = "STD",
            //        TotalfinancedAmount = 0
            //    },
            //    Terms = new TermData
            //    {
            //        Payment = 0,
            //        SecurityDeposit = 0.0,
            //        RatecardID = 0,
            //        Term = 0,
            //        LeaseType = "",
            //        PurchaseOption = ""
            //    },
            //    Vendor = new Vendor
            //    {
            //        DealerContactName = "",
            //        DealerContactEmail = "",
            //        DealerContactphone = ""
            //    },
            //    Lessee = new Lessee
            //    {
            //        LegalName = "test",
            //        Address1 = "",
            //        City = "",
            //        State = "",
            //        Zip = "",
            //        Phone = "",
            //        Contact = ""
            //    },
            //    Assets = new List<Asset>()
            //    {
            //        new Asset
            //        {
            //            Quantity = 1,
            //            Description = "",
            //            SerialNumber = "",
            //            Model = "",
            //            Manufacturer = "",
            //            TotalAmount = 0,
            //            IsUsed = 0
            //        }
            //    }
            //};

            var dealerProfile = _profileRepo.GetDealerProfile();

            var submitCreditAppRequest = new SubmitCreditAppRequest
            {
                Application = new CreditAppMetaData
                {
                    EnteredBy            = dealerProfile.DealerContactName,
                    ApplicationType      = "New",
                    ApplicationFormat    = "STD",
                    TotalFinancedAmount  = creditApp.TotalFinancedAmount,
                    MaintenanceFeeAmount = creditApp.MaintenanceFeeAmount,
                    Notes = creditApp.Comments
                },
                Terms = new TermData
                {
                    Payment         = creditApp.Payment,    //from quote
                    SecurityDeposit = 0.0,
                    RatecardID      = creditApp.RateCardId, //from quote
                    Term            = creditApp.DesiredFinanceTerm,
                    LeaseType       = "",                   //new field on screen, wait for Carol to get back to us
                    PurchaseOption  = creditApp.DesiredPurchaseOption
                },
                Vendor = new Vendor
                {
                    DealerName         = dealerProfile.DealerName,
                    DealerContactName  = dealerProfile.DealerContactName,
                    DealerContactEmail = dealerProfile.DealerContactEmail,
                    DealerContactPhone = dealerProfile.DealerContactPhone,
                    DealerRelationship = "Booking"
                },
                Lessee = new Lessee
                {
                    LegalName    = creditApp.CompanyName,
                    Address1     = creditApp.MailingAddress,
                    City         = creditApp.City,
                    State        = creditApp.State,
                    Zip          = creditApp.PostalCode,
                    Phone        = creditApp.PhoneNumber,
                    DBA          = creditApp.DBA,
                    Contact      = creditApp.ContactName,
                    ContactEmail = creditApp.ContactEmail,
                    ContactPhone = creditApp.ContactPhone
                },
                Assets = new List <Asset>()
                {
                    new Asset
                    {
                        //new fields on screen, wait for Carol to get back to us
                        Quantity     = 1,
                        Description  = creditApp.EquipmentDescription,
                        TotalAmount  = creditApp.TotalAmount,
                        SerialNumber = "",
                        Model        = "",
                        Manufacturer = "",
                        IsUsed       = 0
                    }
                },
                Guarantors = new List <Guarantor>()
                {
                    new Guarantor
                    {
                        FirstName     = creditApp.GuarantorFirstName,
                        MiddleInitial = creditApp.GuarantorMiddleInitial,
                        LastName      = creditApp.GuarantorLastName,
                        Address       = creditApp.GuarantorAddress,
                        City          = creditApp.GuarantorCity,
                        State         = creditApp.GuarantorState,
                        Zip           = creditApp.GuarantorZip
                    }
                }
            };

            var response = await WebServiceClientBase.Post <SubmitCreditAppRequest, SubmitCreditAppResponse>(Constants.CreditAppUri, submitCreditAppRequest, true);

            return(response);
        }
        public async Task <MonthlyPaymentResponse> GetMonthlyPayments(Quote quote)
        {
            //loop through quote rate cards and maintenancy types to create list of PaymentCalculationParameterSets
            //terms, purchase options,
            IEnumerable <int>    terms            = quote.Terms.Select(t => t.Term);
            IEnumerable <string> maintenanceTypes = quote.MaintenanceTypes.Select(m => m.MaintenanceTypeDescription);
            IEnumerable <string> purchaseOptions  = quote.PurchaseOptions.Select(p => p.PurchaseOptionDesc);

            var paymentParamList = new List <PaymentCalculationParameterSet> ();

            foreach (RateCardLocal card in quote.RateCards)
            {
                if (maintenanceTypes.Count() > 0)
                {
                    foreach (string mtype in maintenanceTypes)
                    {
                        //need to create a set for each rate card/maint type combo
                        //var paymentSet = new PaymentCalculationParameterSet () {
                        //	RateCardID = card.RateCardID,
                        //	EquipmentCost = quote.EquipmentAmount,
                        //	NumberOfPoints = quote.Points,
                        //	MaintenanceType = mtype,
                        //	MaintenanceAmount = 0,
                        //	IncludeInvalidPayments = 0,
                        //	AdvancePayments = new List<AdvancePayment> { new AdvancePayment { AdvancePaymentValue = quote.PassThrough } },
                        //	PurchaseOptions = purchaseOptions.ToList(),
                        //	Terms = terms.ToList()
                        //};
                        //paymentParamList.Add (paymentSet);



                        var payment = new PaymentCalculationParameterSet()
                        {
                            RateCardID             = card.RateCardID,
                            EquipmentCost          = quote.EquipmentAmount,
                            NumberOfPoints         = quote.Points,
                            MaintenanceType        = mtype.ToString(),
                            MaintenanceAmount      = quote.PassThrough,
                            IncludeInvalidPayments = 0,
                            AdvancePayments        = quote.AdvancePayments,
                            //AdvancePayments = new List<AdvancePayment> { new AdvancePayment { AdvancePaymentDescription = "Pass Through", AdvancePaymentValue = quote.PassThrough } },
                            PurchaseOptions = purchaseOptions.ToList(),
                            Terms           = terms.ToList()
                        };
                        paymentParamList.Add(payment);
                    }
                }
                else
                {
                    var paymentSet = new PaymentCalculationParameterSet()
                    {
                        RateCardID             = card.RateCardID,
                        EquipmentCost          = quote.EquipmentAmount,
                        NumberOfPoints         = quote.Points,
                        MaintenanceType        = "",
                        MaintenanceAmount      = quote.PassThrough,
                        IncludeInvalidPayments = 0,
                        AdvancePayments        = new List <AdvancePayment> {
                            new AdvancePayment {
                                AdvancePaymentDescription = "Pass Through", AdvancePaymentValue = quote.PassThrough
                            }
                        },
                        PurchaseOptions = purchaseOptions.ToList(),
                        Terms           = terms.ToList()
                    };
                    paymentParamList.Add(paymentSet);
                }
            }
            var monthlyPaymentRequest = new MonthlyPaymentRequest()
            {
                CalculatePayments = paymentParamList
            };

            //TODO: mocked this out for testing, replace with user inputs
            //var paymentParamList = new List<PaymentCalculationParameterSet>()
            //{
            //    new PaymentCalculationParameterSet()
            //    {
            //        RateCardID = 8509,
            //        EquipmentCost = 50000,
            //        NumberOfPoints = 3,
            //        MaintenanceType = "TPM",
            //        MaintenanceAmount = 1000,
            //        IncludeInvalidPayments = 0,
            //        AdvancePayments = new List<AdvancePayment> { new AdvancePayment { AdvancePaymentValue = 0 } },
            //        PurchaseOptions = new List<string> { "FMV Lease", "FMV Rental" },
            //        Terms = new List<int> { 36, 39, 48, 60 }
            //    }
            //};
            //var monthlyPaymentRequest = new MonthlyPaymentRequest()
            //{
            //    CalculatePayments = paymentParamList
            //};

            var response = await WebServiceClientBase.Post <MonthlyPaymentRequest, MonthlyPaymentResponse> (Constants.MonthlyPaymentUri, monthlyPaymentRequest, true);

            ////TODO: mocked this out for testing, replace with user inputs
            //var paymentParamList = new List<PaymentCalculationParameterSet>()
            //{
            //    new PaymentCalculationParameterSet()
            //    {
            //        RateCardID = 9816,
            //        EquipmentCost = 50000,
            //        NumberOfPoints = 3,
            //        MaintenanceType = "TPM",
            //        MaintenanceAmount = 1000,
            //        IncludeInvalidPayments = 0,
            //        AdvancePayments = new List<AdvancePayment> { new AdvancePayment { AdvancePaymentValue = 0 } },
            //        PurchaseOptions = new List<string> { "FMV Lease", "FMV Rental" },
            //        Terms = new List<int> { 36, 39, 48, 60 }
            //    }
            //};
            //var monthlyPaymentRequest = new MonthlyPaymentRequest()
            //{
            //    CalculatePayments = paymentParamList
            //};


            return(response);
        }
Пример #11
0
        public async Task <ObservationSaveResponse> ObservationSave(string email, Observation observation)
        {
            //need to call all the saves
            ObservationSaveResponse returnValue = new ObservationSaveResponse();

            //observation
            var request = new ObservationUpdateRequest
            {
                user_email     = email,
                observation_id = observation.Observation_id,
                indicator_id   = observation.Indicator_id,
                site_id        = observation.Site_id,
                begin_date     = (System.DateTime)observation.Begin_Date,
                end_date       = (System.DateTime)observation.End_Date
            };


            var response = await WebServiceClientBase.Post <ObservationUpdateRequest, ObservationUpdateResponse>(Constants.OperationUpdateUri, request, true);

            if (response != null)
            {
                observation.Observation_id  = response.observation_id;
                observation.ModifiedLocally = false;

                //save observation entry
                foreach (ObservationEntry entry in observation.ObservationEntries)
                {
                    var entryRes = await ObservationEntryUpdate(entry.ObservationEntryId == null? 0 : (int)entry.ObservationEntryId,
                                                                observation.Observation_id,
                                                                entry.Indicator_Age_Range_Id == null? 0 : (int)entry.Indicator_Age_Range_Id,
                                                                entry.Indicator_Gender,
                                                                entry.Numerator == null? 0 : (int)entry.Numerator,
                                                                entry.Denominator == null? 0 : (int)entry.Denominator,
                                                                entry.Count == null? 0 : (int)entry.Count,
                                                                entry.Rate == null? 0 : (int)entry.Rate,
                                                                entry.Yes_No == null?false : (bool)entry.Yes_No,
                                                                email);

                    if (entryRes != null)
                    {
                        entry.ObservationEntryId = entryRes.observation_entry_id;
                        entry.ModifiedLocally    = false;
                    }
                }

                //save observation change
                foreach (ObservationChange change in observation.Changes)
                {
                    var changeRes = await ObservationChangeUpdate(change.Description, observation.Observation_id, change.ChangeId, email);

                    if (changeRes != null)
                    {
                        change.ChangeId        = changeRes.observation_change_id;
                        change.ModifiedLocally = false;
                    }
                }

                //save observation comment
                foreach (ObservationComment comment in observation.Comments)
                {
                    var commentRes = await ObservationCommentUpdate(comment.Comment, observation.Observation_id, comment.CommentId, email);

                    if (commentRes != null)
                    {
                        comment.CommentId       = commentRes.observation_comment_id;
                        comment.ModifiedLocally = false;
                    }
                }

                //save observation attachment
                foreach (ObservationAttachment attach in observation.Attachments)
                {
                    //byte[] file = new byte[attach.Bytes.Length];
                    //int result = fileBytes.InputStream.Read(file, 0, fileBytes.ContentLength);
                    //attachment.attachment = file;
                    //attachment.approved = false;
                    //attachment.createdby_userid = CurrentUser.Id;
                    //attachment.created_date = DateTime.Now;
                    //db.t_observation_attachment.Add(attachment);
                    //db.SaveChanges();
                    var buffer = attach.Bytes;
                    if (buffer != null)
                    {
                        string s = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);

                        var attachRes = await ObservationAttachmentUpdate(attach.Bytes, s, attach.Attachment_File_Name, observation.Observation_id, attach.AttachmentId, email);

                        if (attachRes != null)
                        {
                            attach.AttachmentId    = attachRes.observation_attachment_id;
                            attach.ModifiedLocally = false;
                        }
                    }
                }
            }
            else
            {
                returnValue.ErrorStatusCode = 500;
            }

            returnValue.observation = observation;
            return(returnValue);
        }