Ejemplo n.º 1
0
        public async Task <IActionResult> PurchasePlanPost(int?id, IFormCollection collection)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var subscriberToUpdate = await _context.Subscribers.SingleOrDefaultAsync(s => s.SubscriberID == Convert.ToInt32(collection["SubscriberId"]));

            if (await TryUpdateModelAsync(
                    subscriberToUpdate,
                    "",
                    s => s.FirstName, s => s.MiddleName, s => s.LastName, s => s.AddressLine1, s => s.AddressLine2, s => s.City, s => s.State, s => s.ZipCode, s => s.County, s => s.PhoneNumber, s => s.EmailAddress, s => s.SocialSecurityNumber, s => s.IsUSCitizen, s => s.IsMilitary, s => s.IsStudent, s => s.IsOnMedicare, s => s.IsOnDisability, s => s.EmploymentIncome, s => s.InvestmentIncome, s => s.AlimonyChildSupport))
            {
                try
                {
                    var _confirmation = RandomString(10);
                    var _enrollment   = new Models.Enrollment {
                        InsurancePlanID = (int)id, PlanYear = DateTime.Now.Year, SubscriberID = Convert.ToInt32(collection["SubscriberId"]), ConfirmationCode = _confirmation, TimeStamp = DateTime.Now
                    };
                    TempData["confirmation"] = _confirmation;
                    _context.Add(_enrollment);
                    await _context.SaveChangesAsync();

                    var filteredData = FullEnrollmentData.GetFullEnrollmentData(_context, _enrollment.EnrollmentID);

                    AzureStorageHelper helper = new AzureStorageHelper(ConfigurationManager.AppSettings["AzS_StorageConnectionString"], ConfigurationManager.AppSettings["AzS_StorageContainerName"]);

                    helper.UploadDataToAzureStorage(
                        $"{filteredData.EnrollmentID}-{filteredData.SubscriberID}-{filteredData.HouseholdMemberID}.json",
                        JsonConvert.SerializeObject(filteredData, Formatting.Indented));


                    return(RedirectToAction("Confirm"));
                }
                catch (DbUpdateException ex)
                {
                    //Log the error (uncomment ex variable name and write a log.)
                    ModelState.AddModelError("", "Unable to save changes. " +
                                             "Try again, and if the problem persists, " +
                                             "see your system administrator." + ex.Message);
                }
            }

            return(View(subscriberToUpdate));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateApplication(
            [Bind("ZipCode,EmploymentIncome,HouseholdMembers")] Models.Subscriber _subscriber)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _subscriber.TimeStamp = DateTime.Now;
                    _context.Add(_subscriber);
                    await _context.SaveChangesAsync();

                    TempData["SubscriberId"] = _subscriber.SubscriberID;
                    return(RedirectToRoute("showplans"));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator." + ex.Message);
            }
            return(View(_subscriber));
        }