Beispiel #1
0
 public void run()
 {
     var result = new IssuePolicy().Handle(new IssuePolicy.Request {
         Amount = 1, ClientId = 10, Product = "OCTA"
     });
     var respone = result.Match <string>(ok: ok => "1", errors => (-1).ToString());
 }
        public async Task <bool> IssueConsumerPolicy(IssuePolicy issuePolicy)
        {
            var con1 = await Context.ConsumerPolicies.Include(t => t.PolicyMaster).FirstOrDefaultAsync(t => t.ConsumerId == issuePolicy.CustomerId);

            con1.PolicyStatus = true;

            var count = await Context.SaveChangesAsync();

            return(count > 0);
            //throw new NotImplementedException();
        }
Beispiel #3
0
        public void run()
        {
            var result = new IssuePolicy().Handle(new IssuePolicy.Request {
                Amount = 1, ClientId = 10, Product = "OCTA"
            });

            var respone = result switch
            {
                (_, ArgumentNullException e, _, _) => - 1,
                (_, _, ArgumentNullException e, _) => - 2,
                (_, _, _, ArgumentNullException e) => - 3,
                (IssuePolicy.Response p, _, _, _)when p.PolicyNumber == 10 => 1, //WHEN?
            };
        public void run()
        {
            var result = new IssuePolicy().Handle(new IssuePolicy.Request {
                Amount = 1, ClientId = 10, Product = "OCTA"
            });

            var respone = result switch
            {
                (_, ClientIdException e, _, _) => - 1,
                (_, _, AmountException e, _) => - 2,
                (_, _, _, ProductException e) => - 3,
                (IssuePolicy.Response p, _, _, _)when p.PolicyNumber == 10 => 1, //WHEN?
                _ => throw new NotImplementedException(),
            };
        public async Task <ActionResult> IssueConsumerPolicy(IssuePolicy ip)
        {
            if (HttpContext.Session.GetString("token") == null)
            {
                return(RedirectToAction("Login", "Auth"));
            }
            ConsumerPolicy cp = new ConsumerPolicy();

            if (ModelState.IsValid)
            {
                var client = new HttpClient();

                string token = HttpContext.Session.GetString("token");

                var contentType = new MediaTypeWithQualityHeaderValue("application/json");
                client.DefaultRequestHeaders.Accept.Add(contentType);
                client.DefaultRequestHeaders.Authorization =
                    new AuthenticationHeaderValue("Bearer", token);

                client.BaseAddress = new Uri("https://localhost:44365/");

                var jsonstring = JsonConvert.SerializeObject(ip);

                var content = new StringContent(jsonstring, System.Text.Encoding.UTF8, "application/json");


                var response = await client.PostAsync("api/Policy/IssueConsumerPolicy", content);

                if (response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("PolicyIssuedSuccessfully", new{ id = ip.CustomerId }));
                }

                else
                {
                    ViewBag.Message = "Failed to issue policy";
                }
            }
            return(View(ip));
        }