예제 #1
0
        public IHttpActionResult DeleteInsurancenformationt(InsuranceInformation insuranceInformation)
        {
            InsuranceInformation _insuranceInformation = _insuranceInformationRepository.Find(x => x.Id == insuranceInformation.Id).FirstOrDefault();

            _insuranceInformation.IsActive = insuranceInformation.IsActive;
            return(Ok(_insuranceInformationRepository.Update(_insuranceInformation)));
        }
        public ActionResult Admin()
        {
            string queryString = @"SELECT Id, FirstName, LastName, EmailAddress, InsuranceTotal from InsuranceInformation";
            List <InsuranceInformation> quoteinformation = new List <InsuranceInformation>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var insuranceinfo = new InsuranceInformation();
                    insuranceinfo.Id             = Convert.ToInt32(reader["Id"]);
                    insuranceinfo.FirstName      = reader["FirstName"].ToString();
                    insuranceinfo.LastName       = reader["LastName"].ToString();
                    insuranceinfo.EmailAddress   = reader["EmailAddress"].ToString();
                    insuranceinfo.InsuranceTotal = Convert.ToInt32(reader["InsuranceTotal"]);
                    quoteinformation.Add(insuranceinfo);
                }
            }
            return(View(quoteinformation));
        }
예제 #3
0
        public IHttpActionResult UpdateInsurancenformationt(InsuranceInformation insuranceInformation)
        {
            InsuranceInformation _insuranceInformation = _insuranceInformationRepository.Find(x => x.Id == insuranceInformation.Id).FirstOrDefault();

            _insuranceInformation.CompanyName = insuranceInformation.CompanyName;
            _insuranceInformation.InsuraceNo  = insuranceInformation.InsuraceNo;
            _insuranceInformation.ExpiryDate  = insuranceInformation.ExpiryDate;
            return(Ok(_insuranceInformationRepository.Update(_insuranceInformation)));
        }
예제 #4
0
        public IHttpActionResult UpdateInsurancenformationt(string ClientId, InsuranceInformation insuranceInformation)
        {
            InsuranceInformation _insuranceInformation = _insuranceInformationRepository.Find(x => x.ClientId == ClientId).FirstOrDefault();

            _insuranceInformation.ClientId    = ClientId;
            _insuranceInformation.CompanyName = insuranceInformation.CompanyName;
            _insuranceInformation.InsuraceNo  = insuranceInformation.InsuraceNo;
            return(Ok(_insuranceInformationRepository.Update(_insuranceInformation)));
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="insurances"></param>
        /// <param name="mrNumber"></param>
        /// <returns></returns>
        private int InsuranceEntry(InsuranceInformation insurances, string mrNumber)
        {
            int             insuranceId;
            tblMbrInsurance tinsurance;

            if (insurances != null)
            {
                tinsurance = new tblMbrInsurance()
                {
                    FinancialName  = insurances.FinancialName,
                    PayorName      = insurances.Payorname,
                    PayorID        = Convert.ToInt32(insurances.PayorId),
                    PlanID         = Convert.ToInt32(insurances.PlanId),
                    PlanName       = insurances.PlanName,
                    PlanType       = insurances.PlanType,
                    SubscriberName = insurances.SubscriberName,
                    MrNumber       = mrNumber,
                    Effective      = insurances.EffectiveDate,
                    Termination    = insurances.TerminationDate,
                    FillingOrder   = insurances.FilingOrder,
                    InsuranceID    = insurances.InsuranceId,
                    MedipacPlanID  = insurances.MedipacPlanId,
                    CreatedBy      = User.Identity.Name,
                    CreatedDate    = DateTime.Now
                };
            }
            else
            {
                tinsurance = new tblMbrInsurance()
                {
                    FinancialName  = "N/A",
                    PayorName      = "N/A",
                    PayorID        = 999,
                    PlanID         = 999,
                    PlanName       = "N/A",
                    PlanType       = "N/A",
                    SubscriberName = "N/A",
                    MrNumber       = mrNumber,
                    Effective      = DateTime.Now,
                    Termination    = DateTime.Now,
                    FillingOrder   = 999,
                    InsuranceID    = 999,
                    MedipacPlanID  = "N/A",
                    CreatedBy      = User.Identity.Name,
                    CreatedDate    = DateTime.Now
                };
            }
            using (var context = new lifeflightapps())
            {
                context.tblMbrInsurances.Add(tinsurance);
                context.SaveChanges();
                insuranceId = tinsurance.MbrInsuranceID;
            }
            return(insuranceId);
        }
예제 #6
0
        public IHttpActionResult AddInsurancenformationt(string ClientId, InsuranceInformation insuranceInformation)
        {
            InsuranceInformation _insuranceInformation = new InsuranceInformation
            {
                ClientId    = ClientId,
                CompanyName = insuranceInformation.CompanyName,
                InsuraceNo  = insuranceInformation.InsuraceNo
            };

            return(Ok(_insuranceInformationRepository.Insert(_insuranceInformation)));
        }
예제 #7
0
        public IHttpActionResult getAppointmentInsurancenformationt(string appointmentid)
        {
            IAppointmentRepository _appointmentRepo = RepositoryFactory.Create <IAppointmentRepository>(ContextTypes.EntityFramework);
            var appointment = _appointmentRepo.Find(x => x.AppointmentId == appointmentid).FirstOrDefault();
            InsuranceInformation _insuranceContact = new InsuranceInformation();

            if (appointment != null)
            {
                _insuranceContact = _insuranceInformationRepository.Find(x => x.Id == appointment.InsuranceId).FirstOrDefault();
            }
            return(Ok(_insuranceContact));
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mrNumber"></param>
        /// <returns></returns>
        private GenServiceModel RetrieveDataFromGenServices(string mrNumber, string vunetId)
        {
            GenServiceModel gsm = new GenServiceModel();
            RetrieveCoverageAndInsurance coverageinfo = new RetrieveCoverageAndInsurance();
            RetrievePatientInformation   patientinfo  = new RetrievePatientInformation();
            RetrieveCensusInformation    censusinfo   = new RetrieveCensusInformation();
            CoverageInfo         coverages            = coverageinfo.GetCoverageAndInsurance(mrNumber, vunetId).Where(c => c.IsActive == true).FirstOrDefault();
            InsuranceInformation insurances           = coverageinfo.GetInsurances(mrNumber, vunetId).Where(i => i.EffectiveDate <= DateTime.Today && (i.TerminationDate >= DateTime.Today || i.TerminationDate == null)).FirstOrDefault();
            Patient     patient = patientinfo.GetPatient(mrNumber, vunetId);
            CensusModel census  = censusinfo.GetCensusRecords(mrNumber, vunetId).FirstOrDefault();

            gsm.PatientDemographics = patient;
            gsm.Coverages           = coverages;
            gsm.Insurances          = insurances;
            gsm.Census = census;

            return(gsm);
        }
예제 #9
0
        public IHttpActionResult getinsurancedetail(int insuranceId)
        {
            InsuranceInformation _insuranceContact = _insuranceInformationRepository.Find(x => x.Id == insuranceId).FirstOrDefault();

            return(Ok(_insuranceContact));
        }
예제 #10
0
        public IHttpActionResult getInsurancenformationt(string ClientId)
        {
            InsuranceInformation _insuranceContact = _insuranceInformationRepository.Find(x => x.ClientId == ClientId).FirstOrDefault();

            return(Ok(_insuranceContact));
        }
예제 #11
0
        public async Task <IActionResult> DeleteBook([FromRoute] int id)
        {
            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            // Get the book from the database
            Documents book = db.Documents.Where(e => e.DocumentId == id).SingleOrDefault();

            if (book == null)
            {
                errorMessage.Message = "Could not find book";
                return(Json(error));
            }

            // Remove the authors and genres from the database
            List <DocumentGenres> genres = db.DocumentGenres.Where(e => e.DocumentId == book.DocumentId).ToList();

            foreach (var documentGenre in genres)
            {
                // Remove the document genres
                db.Remove(documentGenre);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception exception)
                {
                    errorMessage.Message = "Could not remove document genre for the book";
                    return(Json(error));
                }
            }

            // Get the authors for the book
            List <DocumentAuthors> authors = db.DocumentAuthors.Where(e => e.DocumentId == book.DocumentId).ToList();

            foreach (var documentAuthor in authors)
            {
                // Remove the document authors
                db.Remove(documentAuthor);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception exception)
                {
                    errorMessage.Message = "Could not remove document author for the book";
                    return(Json(error));
                }
            }

            // Remove the insurance information for the book
            InsuranceInformation insuranceInformation = db.InsuranceInformation.Where(e => e.InsuranceInformationId == book.InsuranceInformationId).SingleOrDefault();

            if (insuranceInformation != null)
            {
                db.Remove(insuranceInformation);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception exception)
                {
                    errorMessage.Message = "Could not remove insurance information";
                    return(Json(error));
                }
            }

            // Remove the book from the database
            db.Remove(book);

            try
            {
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                errorMessage.Message = "Could not remove book for the book";
                return(Json(error));
            }

            return(Ok(book));
        }
예제 #12
0
        public async Task <IActionResult> GetBookById([FromRoute] int id)
        {
            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            // Get the book by id
            Documents book = db.Documents.Where(e => e.DocumentId == id).SingleOrDefault();

            if (book == null)
            {
                errorMessage.Message = "Could not find book";
                return(Json(error));
            }

            // Get the genres for the book
            List <DocumentGenres>     genreList = db.DocumentGenres.Where(e => e.DocumentId == book.DocumentId).ToList();
            List <BookGenreViewModel> genres    = new List <BookGenreViewModel>();

            foreach (var dbGenre in genreList)
            {
                Genres genre = db.Genres.Where(e => e.GenreId == dbGenre.GenreId).SingleOrDefault();

                if (genre == null)
                {
                    errorMessage.Message = "Could not find the genre for the book";
                    return(Json(error));
                }

                var bookGenre = new BookGenreViewModel
                {
                    GenreId = genre.GenreId,
                    Name    = genre.Title
                };

                genres.Add(bookGenre);
            }

            // Get the authors for the book
            List <DocumentAuthors>     authorList = db.DocumentAuthors.Where(e => e.DocumentId == book.DocumentId).ToList();
            List <BookAuthorViewModel> authors    = new List <BookAuthorViewModel>();

            foreach (var documentAuthor in authorList)
            {
                Authors author = db.Authors.Where(e => e.AuthorId == documentAuthor.AuthorId).SingleOrDefault();

                if (author == null)
                {
                    errorMessage.Message = "Could not find the author for the book";
                    return(Json(error));
                }

                var bookAuthor = new BookAuthorViewModel
                {
                    AuthorId = author.AuthorId,
                    Name     = author.Name
                };

                authors.Add(bookAuthor);
            }

            // Get the insurance information for the book
            InsuranceInformation          bookInsurance        = db.InsuranceInformation.Where(e => e.InsuranceInformationId == book.InsuranceInformationId).SingleOrDefault();
            InsuranceInformationViewModel insuranceInformation = new InsuranceInformationViewModel();

            if (bookInsurance != null)
            {
                insuranceInformation.Cost          = bookInsurance.Cost;
                insuranceInformation.DatePurchased = bookInsurance.DatePurchased.ToString("yyyy-MM-dd");
                insuranceInformation.ReceiptImage  = bookInsurance.ReceiptImage;
                insuranceInformation.IssueDate     = bookInsurance.IssueDate.ToString("yyyy-MM-dd");
            }

            BookDetailsViewModel bookDetails = new BookDetailsViewModel
            {
                Id                   = book.DocumentId,
                Title                = book.Title,
                Authors              = authors.ToArray(),
                Genres               = genres.ToArray(),
                ISBN                 = book.ISBN,
                CheckedOut           = book.CheckedOut,
                Picture              = book.CoverImage,
                Pages                = Convert.ToInt32(book.Pages),
                Publisher            = book.Publisher,
                PublishedDate        = book.PublishedDate.ToString("yyyy-MM-dd"),
                Edition              = book.Edition,
                Description          = book.Description,
                InsuranceInformation = insuranceInformation
            };

            return(Ok(bookDetails));
        }
예제 #13
0
        public async Task <IActionResult> GetMyBooks()
        {
            var id   = "";
            var role = "";

            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            if (User == null)
            {
                errorMessage.Message = "Could not find user for claims";
                return(Json(error));
            }

            try
            {
                id   = User.Claims.Where(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier").SingleOrDefault().Value;
                role = User.Claims.Where(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").SingleOrDefault().Value;
            }
            catch (Exception exception)
            {
                errorMessage.Message = "Id or role was not found";
                return(Json(error));
            }

            if (role == "Personal")
            {
                PersonalUsers personalUser = db.PersonalUsers.Where(e => e.UserId == id).SingleOrDefault();

                if (personalUser == null)
                {
                    errorMessage.Message = "Could not find user profile";
                    return(Json(error));
                }

                // Get books for the user
                List <BookDetailsViewModel> books    = new List <BookDetailsViewModel>();
                List <Documents>            bookList = db.Documents.Where(e => e.UserId == id).ToList();

                foreach (Documents item in bookList)
                {
                    // Get the genres for the book
                    List <DocumentGenres>     genreList = db.DocumentGenres.Where(e => e.DocumentId == item.DocumentId).ToList();
                    List <BookGenreViewModel> genres    = new List <BookGenreViewModel>();

                    foreach (var dbGenre in genreList)
                    {
                        Genres genre = db.Genres.Where(e => e.GenreId == dbGenre.GenreId).SingleOrDefault();

                        if (genre == null)
                        {
                            errorMessage.Message = "Could not find the genre for the book";
                            return(Json(error));
                        }

                        var bookGenre = new BookGenreViewModel
                        {
                            GenreId = genre.GenreId,
                            Name    = genre.Title
                        };

                        genres.Add(bookGenre);
                    }

                    // Get the authors for the book
                    List <DocumentAuthors>     authorList = db.DocumentAuthors.Where(e => e.DocumentId == item.DocumentId).ToList();
                    List <BookAuthorViewModel> authors    = new List <BookAuthorViewModel>();

                    foreach (var documentAuthor in authorList)
                    {
                        Authors author = db.Authors.Where(e => e.AuthorId == documentAuthor.AuthorId).SingleOrDefault();

                        if (author == null)
                        {
                            errorMessage.Message = "Could not find the author for the book";
                            return(Json(error));
                        }

                        var bookAuthor = new BookAuthorViewModel
                        {
                            AuthorId = author.AuthorId,
                            Name     = author.Name
                        };

                        authors.Add(bookAuthor);
                    }

                    // Get the insurance information for the book
                    InsuranceInformation          bookInsurance        = db.InsuranceInformation.Where(e => e.InsuranceInformationId == item.InsuranceInformationId).SingleOrDefault();
                    InsuranceInformationViewModel insuranceInformation = new InsuranceInformationViewModel();

                    if (bookInsurance != null)
                    {
                        insuranceInformation.Cost          = bookInsurance.Cost;
                        insuranceInformation.DatePurchased = bookInsurance.DatePurchased.ToString("yyyy-MM-dd");
                        insuranceInformation.ReceiptImage  = bookInsurance.ReceiptImage;
                        insuranceInformation.IssueDate     = bookInsurance.IssueDate.ToString("yyyy-MM-dd");
                    }

                    BookDetailsViewModel book = new BookDetailsViewModel
                    {
                        Id                   = item.DocumentId,
                        Title                = item.Title,
                        Authors              = authors.ToArray(),
                        Genres               = genres.ToArray(),
                        ISBN                 = item.ISBN,
                        CheckedOut           = item.CheckedOut,
                        Picture              = item.CoverImage,
                        Pages                = Convert.ToInt32(item.Pages),
                        Publisher            = item.Publisher,
                        PublishedDate        = item.PublishedDate.ToString("yyyy-MM-dd"),
                        Edition              = item.Edition,
                        Description          = item.Description,
                        InsuranceInformation = insuranceInformation
                    };

                    books.Add(book);
                }

                return(Ok(books));
            }

            else if (role == "Business")
            {
                BusinessUsers businessUser = db.BusinessUsers.Where(e => e.UserId == id).SingleOrDefault();

                if (businessUser == null)
                {
                    errorMessage.Message = "Could not find user profile";
                    return(Json(error));
                }

                // Get books for the user
                List <BookDetailsViewModel> books    = new List <BookDetailsViewModel>();
                List <Documents>            bookList = db.Documents.Where(e => e.UserId == id).ToList();

                foreach (Documents item in bookList)
                {
                    // Get the genres for the book
                    List <DocumentGenres>     genreList = db.DocumentGenres.Where(e => e.DocumentId == item.DocumentId).ToList();
                    List <BookGenreViewModel> genres    = new List <BookGenreViewModel>();

                    foreach (var dbGenre in genreList)
                    {
                        Genres genre = db.Genres.Where(e => e.GenreId == dbGenre.GenreId).SingleOrDefault();

                        if (genre == null)
                        {
                            errorMessage.Message = "Could not find the genre for the book";
                            return(Json(error));
                        }

                        var bookGenre = new BookGenreViewModel
                        {
                            GenreId = genre.GenreId,
                            Name    = genre.Title
                        };

                        genres.Add(bookGenre);
                    }

                    // Get the authors for the book
                    List <DocumentAuthors>     authorList = db.DocumentAuthors.Where(e => e.DocumentId == item.DocumentId).ToList();
                    List <BookAuthorViewModel> authors    = new List <BookAuthorViewModel>();

                    foreach (var documentAuthor in authorList)
                    {
                        Authors author = db.Authors.Where(e => e.AuthorId == documentAuthor.AuthorId).SingleOrDefault();

                        if (author == null)
                        {
                            errorMessage.Message = "Could not find the author for the book";
                            return(Json(error));
                        }

                        var bookAuthor = new BookAuthorViewModel
                        {
                            AuthorId = author.AuthorId,
                            Name     = author.Name
                        };

                        authors.Add(bookAuthor);
                    }

                    // Get the insurance information for the book
                    InsuranceInformation          bookInsurance        = db.InsuranceInformation.Where(e => e.InsuranceInformationId == item.InsuranceInformationId).SingleOrDefault();
                    InsuranceInformationViewModel insuranceInformation = new InsuranceInformationViewModel();

                    if (bookInsurance != null)
                    {
                        insuranceInformation.Cost          = bookInsurance.Cost;
                        insuranceInformation.DatePurchased = bookInsurance.DatePurchased.ToString("yyyy-MM-dd");
                        insuranceInformation.ReceiptImage  = bookInsurance.ReceiptImage;
                        insuranceInformation.IssueDate     = bookInsurance.IssueDate.ToString("yyyy-MM-dd");
                    }

                    BookDetailsViewModel book = new BookDetailsViewModel
                    {
                        Id                   = item.DocumentId,
                        Title                = item.Title,
                        Authors              = authors.ToArray(),
                        Genres               = genres.ToArray(),
                        ISBN                 = item.ISBN,
                        CheckedOut           = item.CheckedOut,
                        Picture              = item.CoverImage,
                        Pages                = Convert.ToInt32(item.Pages),
                        Publisher            = item.Publisher,
                        PublishedDate        = item.PublishedDate.ToString("yyyy-MM-dd"),
                        Edition              = item.Edition,
                        Description          = item.Description,
                        InsuranceInformation = insuranceInformation
                    };

                    books.Add(book);
                }

                return(Ok(books));
            }

            else if (role == "Employee")
            {
                BusinessEmployees employee = db.BusinessEmployees.Where(e => e.UserId == id).SingleOrDefault();

                if (employee == null)
                {
                    errorMessage.Message = "Could not find user profile";
                    return(Json(error));
                }

                // Get the employer
                BusinessUsers businessUser = db.BusinessUsers.Where(e => e.BusinessUserId == employee.BusinessUserId).SingleOrDefault();

                // Get books for the user
                List <BookDetailsViewModel> books    = new List <BookDetailsViewModel>();
                List <Documents>            bookList = db.Documents.Where(e => e.UserId == businessUser.UserId).ToList();

                foreach (Documents item in bookList)
                {
                    // Get the genres for the book
                    List <DocumentGenres>     genreList = db.DocumentGenres.Where(e => e.DocumentId == item.DocumentId).ToList();
                    List <BookGenreViewModel> genres    = new List <BookGenreViewModel>();

                    foreach (var dbGenre in genreList)
                    {
                        Genres genre = db.Genres.Where(e => e.GenreId == dbGenre.GenreId).SingleOrDefault();

                        if (genre == null)
                        {
                            errorMessage.Message = "Could not find the genre for the book";
                            return(Json(error));
                        }

                        var bookGenre = new BookGenreViewModel
                        {
                            GenreId = genre.GenreId,
                            Name    = genre.Title
                        };

                        genres.Add(bookGenre);
                    }

                    // Get the authors for the book
                    List <DocumentAuthors>     authorList = db.DocumentAuthors.Where(e => e.DocumentId == item.DocumentId).ToList();
                    List <BookAuthorViewModel> authors    = new List <BookAuthorViewModel>();

                    foreach (var documentAuthor in authorList)
                    {
                        Authors author = db.Authors.Where(e => e.AuthorId == documentAuthor.AuthorId).SingleOrDefault();

                        if (author == null)
                        {
                            errorMessage.Message = "Could not find the author for the book";
                            return(Json(error));
                        }

                        var bookAuthor = new BookAuthorViewModel
                        {
                            AuthorId = author.AuthorId,
                            Name     = author.Name
                        };

                        authors.Add(bookAuthor);
                    }

                    // Get the insurance information for the book
                    InsuranceInformation          bookInsurance        = db.InsuranceInformation.Where(e => e.InsuranceInformationId == item.InsuranceInformationId).SingleOrDefault();
                    InsuranceInformationViewModel insuranceInformation = new InsuranceInformationViewModel();

                    if (bookInsurance != null)
                    {
                        insuranceInformation.Cost          = bookInsurance.Cost;
                        insuranceInformation.DatePurchased = bookInsurance.DatePurchased.ToString("yyyy-MM-dd");
                        insuranceInformation.ReceiptImage  = bookInsurance.ReceiptImage;
                        insuranceInformation.IssueDate     = bookInsurance.IssueDate.ToString("yyyy-MM-dd");
                    }

                    BookDetailsViewModel book = new BookDetailsViewModel
                    {
                        Id                   = item.DocumentId,
                        Title                = item.Title,
                        Authors              = authors.ToArray(),
                        Genres               = genres.ToArray(),
                        ISBN                 = item.ISBN,
                        CheckedOut           = item.CheckedOut,
                        Picture              = item.CoverImage,
                        Pages                = Convert.ToInt32(item.Pages),
                        Publisher            = item.Publisher,
                        PublishedDate        = item.PublishedDate.ToString("yyyy-MM-dd"),
                        Edition              = item.Edition,
                        Description          = item.Description,
                        InsuranceInformation = insuranceInformation
                    };

                    books.Add(book);
                }

                return(Ok(books));
            }

            errorMessage.Message = "An error has occurred";
            return(Ok(error));
        }
예제 #14
0
        public async Task <IActionResult> EditInsuranceInformation([FromRoute] int id, [FromBody] InsuranceInformation insuranceInfo)
        {
            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            return(Ok());
        }
예제 #15
0
        public async Task <IActionResult> AddInsuranceInformation([FromRoute] int id, [FromBody] InsuranceInformation insuranceInfo)
        {
            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            if (!ModelState.IsValid)
            {
                errorMessage.Message = "Model is missing required fields";
                return(Json(error));
            }

            Documents book = db.Documents.Where(e => e.DocumentId == id).SingleOrDefault();

            if (book == null)
            {
                errorMessage.Message = "Could not find book";
                return(Json(error));
            }

            // Handle the image upload for the insurance information
            if (!String.IsNullOrWhiteSpace(insuranceInfo.ReceiptImage))
            {
                // Upload image for receipt
                var fileName = await fileController.UploadImage(insuranceInfo.ReceiptImage, Request);

                if (String.IsNullOrWhiteSpace(fileName))
                {
                    errorMessage.Message = "Image upload encountered an error";
                    return(Json(error));
                }

                insuranceInfo.ReceiptImage = fileName;
            }

            // Add insurance information to the database
            db.InsuranceInformation.Add(insuranceInfo);

            try
            {
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                errorMessage.Message = "Could not add insurance information";
                return(Json(error));
            }

            // Add link to the book
            book.InsuranceInformationId = insuranceInfo.InsuranceInformationId;
            db.Entry(book).State        = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                errorMessage.Message = "Could not add insurance information to book";
                return(Json(error));
            }

            return(Ok(book));
        }
예제 #16
0
        public bool CheckInsurances(InsuranceInformation insuranceBase, string insuranceResult)
        {
            var externalInsurance = _insuranceCoder.Decode(insuranceResult);

            return(externalInsurance.Equals(insuranceBase));
        }