public bool SelectedPet(PetClaimServiceViewModels model)
        {
            // Gets the selected pet value...
            ApplicationSession.GlobalParameters.SelectedPetNameId = model.Id;
            ApplicationSession.GlobalParameters.SelectedPetName   = model.PetName;

            // Returns true if the selected pet value if not equals to 0, else returns false...
            return(ApplicationSession.GlobalParameters.SelectedPetNameId != 0 ? true : false);
        }
        public string SubmitClaim(PetClaimServiceViewModels model)
        {
            // Gets the selected filename...
            model.FileName = ApplicationSession.GlobalParameters.SelectedPetFileName;
            StringBuilder submitedfiles = new StringBuilder();

            submitedfiles.Clear();

            // Checks if file has been uploaded already, by checking the ApplicationSession.GlobalParameters.SelectedPetFileName value...
            if (!string.IsNullOrEmpty(model.FileName))
            {
                // Starts connecting to the database...
                using (PetSureDatabaseEntities dbo = new PetSureDatabaseEntities())
                {
                    // Start the database transaction to ensure that the Entity Framework executes commands on the database within the context of that transaction...
                    using (System.Data.Entity.DbContextTransaction transaction = dbo.Database.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted))
                    {
                        try
                        {
                            // Checks if the selected pet name is a valid petname...
                            int petId      = dbo.PetLists.Where(x => x.PetName == model.PetName).FirstOrDefault().PetId;
                            int existCount = dbo.PetClaimServices.Where(x => x.PetId == petId).Count();
                            if (existCount > 0)
                            {
                                // Remove first all the existing records of the selected pet in PetClaimService table...
                                dbo.PetClaimServices.RemoveRange(dbo.PetClaimServices.Where(x => x.PetId == petId));
                                // Saves all the changes made on the PetClaimService table...
                                dbo.SaveChanges();

                                // Re-submit all the submitted new invoice file for the selected pet for pet claim...
                                foreach (var item in ApplicationSession.GlobalParameters.PetClaimServiceList)
                                {
                                    PetService.MVC.Models.PetClaimService petModel = new PetService.MVC.Models.PetClaimService();
                                    petModel.PetId = petId;
                                    submitedfiles.Append(string.IsNullOrEmpty(submitedfiles.ToString())? petModel.FileName = item.FileName: String.Concat(", ", petModel.FileName = item.FileName));
                                    petModel.FilePath       = item.FilePath;
                                    petModel.PetClaimedDate = DateTime.Now;
                                    dbo.PetClaimServices.Add(petModel);
                                    dbo.SaveChanges();
                                }

                                // Commits the underlying store transaction...
                                transaction.Commit();
                                return(String.Format("Thank you for re-submitting ''{0}'' for {1}", submitedfiles.ToString(), model.PetName));
                            }
                            else
                            {
                                // Submit all the submitted new invoice file for the selected pet for pet claim...
                                foreach (var item in ApplicationSession.GlobalParameters.PetClaimServiceList)
                                {
                                    PetService.MVC.Models.PetClaimService petModel = new PetService.MVC.Models.PetClaimService();
                                    petModel.PetId = petId;
                                    submitedfiles.Append(string.IsNullOrEmpty(submitedfiles.ToString()) ? petModel.FileName = item.FileName : String.Concat(", ", petModel.FileName = item.FileName));
                                    petModel.FilePath       = item.FilePath;
                                    petModel.PetClaimedDate = DateTime.Now;
                                    dbo.PetClaimServices.Add(petModel);
                                    dbo.SaveChanges();
                                }

                                // Commits the underlying store transaction...
                                transaction.Commit();
                                return(String.Format("Thank you for submitting ''{0}'' for {1}", submitedfiles.ToString(), model.PetName));
                            }
                        }
                        catch (Exception)
                        {
                            // ROLLBACK TRANSACTION FOR ANY UNHANDLED EXCEPTION...
                            transaction.Rollback();
                        }
                        // CLEANS UP TRANSACTION OBJECT AND ENSURES THE ENTITY FRAMEWORK IS NO LONGER USING THAT TRANSACTION...
                        transaction.Dispose();
                    }
                }
            }
            return("No Invoice Uploaded Yet!");
        }