예제 #1
0
        public HttpResponseMessage AddQuote(Quote quote)
        {
            var repo   = new QuoteRepo();
            var result = repo.CreateQuote(quote);

            return(Request.CreateAddRecordResponse(result));
        }
예제 #2
0
        public HttpResponseMessage GetRandomQuote(int userId)
        {
            var repo   = new QuoteRepo();
            var result = repo.GetRandomQuote(userId);

            return(Request.CreateResponse(result));
        }
예제 #3
0
        public HttpResponseMessage ListShows()
        {
            var repo   = new QuoteRepo();
            var result = repo.GetQuotes();

            return(Request.CreateListRecordResponse(result));
        }
예제 #4
0
        public async Task <PolicyQuote> SaveQuoteAsync(PolicyQuote quote)
        {
            //PolicyQuote savedQuote = Context.Quote.Add(quote);
            PolicyQuote savedQuote = QuoteRepo.Insert(quote);
            await Context.SaveChangesAsync();

            return(savedQuote);
        }
        public IActionResult GetQuotes(int count)
        {
            var quotes = QuoteRepo.FindAllQuotes();

            if (count > 0)
            {
                quotes = quotes.TakeRandom(count);
            }

            return(Ok(quotes));
        }
 public void InitializeFixture()
 {
     _quotes    = new Dictionary <Guid, IQuote>();
     _books     = new Dictionary <string, SortedQuotes>();
     _quoteRepo = new QuoteRepo(_quotes, _books);
 }
예제 #7
0
        public Policy SavePolicy(Guid guid, Client client, Vehicle vehicle, Broker broker)
        {
            PolicyQuote quote = QuoteRepo.GetByID(guid);

            if (quote == null)
            {
                throw new Exception("The supplied guid not exists");
            }
            if (quote.Period.Count > 0)
            {
                throw new Exception("The quote already is transferred to policy");
            }

            //check if exists policy with quote
            //check if the quid belong to the brokee or not
            //check againts quote starting date, and modify if we need!!!

            string policyNumber = GetNextPolicyNumber(quote.Product_ID);

            client.ClientCode = policyNumber;

            Policy policy = new Policy()
            {
                PolicyNumber    = policyNumber,
                PolicyStartDate = quote.PolicyStartDate,
                PolicyEndDate   = quote.PolicyEndDate,
                IsFixedTerm     = quote.PolicyType_ID == PolicyTypes.FixedTerm ? true : false,
                Product_ID      = Convert.ToInt32(quote.Product_ID),
                Status_ID       = Convert.ToInt32(PolicyStatuses.Policy),
                Broker_ID       = quote.Broker_ID,
                CreatedBy_ID    = 1, //sysadmin, to do
                Client          = client,
                Vehicle         = vehicle,
                PolicyPeriods   = new List <PolicyPeriod>()
                {
                    new PolicyPeriod()
                    {
                        PeriodStartDate         = quote.PolicyStartDate,
                        PeriodEndDate           = quote.PolicyEndDate,
                        Premium                 = quote.Premium,
                        IsLastPeriod            = true,
                        PeriodNumber            = 1,
                        PaymentType_ID          = Convert.ToInt32(quote.PolicyPaymentMethod_ID),
                        PreviousPolicyPeriod_ID = null,
                        Quote       = quote,
                        Installment = new List <PolicyInstallment>()
                        {
                            new PolicyInstallment()
                            {
                                Nr      = 1,
                                Type    = 1,
                                DueDate = quote.PolicyStartDate,
                                Value   = quote.Premium
                            }
                        },
                        InsurancePolicies = new List <InsurancePolicy>()
                        {
                            new InsurancePolicy()
                            {
                                Company      = Convert.ToInt32(quote.InsuranceCompany),
                                PolicyNumber = quote.InsurancePolicyNumber,
                                StartDate    = quote.InsuranceStartDate,
                                EndDate      = quote.InsuranceEndDate
                            }
                        }
                    }
                }
            };

            Policy savedPolicy = PolicyRepo.Insert(policy);

            SaveChanges();

            return(savedPolicy);
        }