//When Next is clicked Again on Step 1, update the information
 public void UpdateApplication(RegisterModel objRegisterModel, string oldPassword)
 {
     using (ClientApplicationRepository car = new ClientApplicationRepository())
     {
         var client = getApplicant(objRegisterModel.identityNumber);
         client.title           = objRegisterModel.title;
         client.firstName       = objRegisterModel.firstName;
         client.lastName        = objRegisterModel.lastName;
         client.province        = objRegisterModel.province;
         client.contactNumber   = objRegisterModel.contactNumber;
         client.emailAdress     = objRegisterModel.Email;
         client.physicalAddress = renderPhysicalAddressSave(objRegisterModel.streetAddress, objRegisterModel.suburb, objRegisterModel.city, objRegisterModel.postalCode.ToString());
         if (objRegisterModel.postalOffice == null)
         {
             client.postalAddress = renderPhysicalAddressSave(objRegisterModel.streetAddress, objRegisterModel.suburb, objRegisterModel.city, objRegisterModel.postalCode.ToString());
         }
         else
         {
             client.postalAddress = renderPostalAddressSave(objRegisterModel.postalOffice, objRegisterModel.town, objRegisterModel.boxpostalCode);
         }
         car.Update(client);
         DataContext dc = new DataContext();
         dc.SaveChanges();
     }
     updatePassword(objRegisterModel, oldPassword);
 }
        public UnitOfWorkWebApi(ApplicationContext context) : base(context)
        {
            /*************Authorization************/
            Claims                 = new ClaimRepository(context);
            ClientApplications     = new ClientApplicationRepository(context);
            ClientApplicationUtils = new ClientApplicationUtilRepository(context);
            RoleClaims             = new RoleClaimRepository(context);
            RoleEntityClaims       = new RoleEntityClaimRepository(context);
            Roles            = new RoleRepository(context);
            UserClaims       = new UserClaimRepository(context);
            UserEntityClaims = new UserEntityClaimRepository(context);
            Users            = new UserRepository(context);
            UserRoles        = new UserRoleRepository(context);
            UserUtils        = new UserUtilRepository(context);
            Applications     = new ApplicationRepository(context);
            ApplicationUsers = new ApplicationUserRepository(context);
            /*************Authorization************/

            /*************Instances************/
            Matches = new MatchRepository(context);
            Teams   = new TeamRepository(context);
            Players = new PlayerRepository(context);
            Stats   = new StatRepository(context);
            /*********End of Instances*********/
        }
Beispiel #3
0
        public void createDocuments(int appID)
        {
            var CADocRepo = new ClientApplicationDocumentRepository();
            var docList   = (from x in CADocRepo.GetAll()
                             where x.applicationID == appID
                             select x).ToList();

            var CArepo = new ClientApplicationRepository();
            ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table
            var polRepo = new PolicyHolderRepository();

            foreach (var doc in docList)
            {
                using (var polDocRepo = new PolicyDocumentRepository())
                {
                    PolicyDocument pd = new PolicyDocument()
                    {
                        policyNo     = polRepo.Find(x => x.IDNumber == client.IDNumber).SingleOrDefault().policyNo,
                        IDNumber     = doc.IDNumber,
                        fullname     = doc.fullname,
                        documentName = doc.documentName,
                        document     = doc.document
                    };
                    polDocRepo.Insert(pd);
                }
            }
        }
 public ClientApplication getApplicant(string id)
 {
     using (var ClientArepo = new ClientApplicationRepository())
     {
         return(ClientArepo.Find(x => x.IDNumber == id).First());
     }
 }
Beispiel #5
0
 public ClientApplication getApplicationByIDNumber(string ID)
 {
     using (var CArepo = new ClientApplicationRepository())
     {
         return(CArepo.Find(x => x.IDNumber == ID).FirstOrDefault());
     }
 }
Beispiel #6
0
        public void createPolicyHolder(int appID)
        {
            var CArepo = new ClientApplicationRepository();

            try
            {
                ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table
                PolicyHolder      ph     = new PolicyHolder()                                            //initialise the client as policy holder
                {
                    IDNumber        = client.IDNumber,
                    title           = client.title,
                    firstName       = client.firstName,
                    lastName        = client.lastName,
                    province        = client.province,
                    contactNumber   = client.contactNumber,
                    emailAdress     = client.emailAdress,
                    physicalAddress = client.physicalAddress,
                    postalAddress   = client.postalAddress,
                    packageID       = client.packageID,
                    dateStarted     = DateTime.Now,
                    status          = "Active"
                };
                using (var polRepo = new PolicyHolderRepository())
                {
                    polRepo.Insert(ph); //Save as policy holder
                    var rolb = new RoleBusiness();
                    rolb.AddUserToRole(ph.IDNumber, "Policy Holder");
                }
            }
            catch (Exception ex)
            {
                feedback = "Request unsuccessfull";
            }
        }
Beispiel #7
0
 public List <ClientApplication> getAllApplications()
 {
     using (var CArepo = new ClientApplicationRepository())
     {
         return((from x in CArepo.GetAll()
                 select x).ToList());
     }
 }
Beispiel #8
0
 public List <ClientApplication> getDeclinedApplications()
 {
     using (var CArepo = new ClientApplicationRepository())
     {
         return((from x in CArepo.GetAll()
                 where x.status == "Declined"
                 select x).ToList());
     }
 }
Beispiel #9
0
 public List <ClientApplication> getIncompleteApplications()
 {
     using (var CArepo = new ClientApplicationRepository())
     {
         return((from x in CArepo.GetAll()
                 where x.status == "Awaiting outstanding supporting documents"
                 select x).ToList());
     }
 }
 public void AppStatusUpdate(string id)
 {
     using (var ClientArepo = new ClientApplicationRepository())
     {
         ClientApplication client = ClientArepo.Find(x => x.IDNumber == id).SingleOrDefault();
         client.status = "Proccessing";
         ClientArepo.Update(client);
     }
 }
 public void ChoosePackage(int packID, string id)
 {
     using (var CArepo = new ClientApplicationRepository())
     {
         ClientApplication client = CArepo.Find(x => x.IDNumber == id).SingleOrDefault();
         client.packageID = packID;
         CArepo.Update(client);
     }
 }
Beispiel #12
0
 public void updateAppStatus(int appID, string stat)
 {
     using (var CArepo = new ClientApplicationRepository())
     {
         ClientApplication x = CArepo.GetById(appID);
         x.status = stat;
         CArepo.Update(x);
     }
 }
Beispiel #13
0
        public List <ClientApplicationDocument> AttachedDocList(int appID)
        {
            var ClientArepo = new ClientApplicationRepository();
            var CADocRepo   = new ClientApplicationDocumentRepository();
            var docList     = (from x in CADocRepo.GetAll()
                               where x.applicationID == appID
                               select x).ToList();

            return(docList); //list of supporting documents
        }
Beispiel #14
0
        public List <ClientApplicationBeneficiary> getBeneficiariesByAppID(int appID)
        {
            var BenefitiaryArepo     = new ClientApplicationBeneficiaryRepository();
            var ClientArepo          = new ClientApplicationRepository();
            ClientApplication client = ClientArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client
            List <ClientApplicationBeneficiary> cab = new List <ClientApplicationBeneficiary>();

            cab = (from cl in ClientArepo.GetAll()
                   join ben in BenefitiaryArepo.GetAll()
                   on cl.IDNumber equals ben.IDNumber
                   where ben.IDNumber == client.IDNumber
                   select ben).ToList();
            return(cab);
        }
        public List <ClientApplicationBeneficiary> getBeneficiariesByClientID(string ID)
        {
            var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository();
            var ClientArepo      = new ClientApplicationRepository();

            List <ClientApplicationBeneficiary> cab = new List <ClientApplicationBeneficiary>();

            cab = (from cl in ClientArepo.GetAll()
                   join ben in BenefitiaryArepo.GetAll()
                   on cl.IDNumber equals ben.IDNumber
                   where ben.IDNumber == ID
                   select ben).ToList();
            return(cab);
        }
Beispiel #16
0
        public ApplicationViewModel getApplication(int appID)
        {
            var CArepo = new ClientApplicationRepository();
            ApplicationViewModel appView = new ApplicationViewModel();

            try
            {
                ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table
                appView.applicationID   = appID;
                appView.IDNumber        = client.IDNumber;
                appView.title           = client.title;
                appView.firstName       = client.firstName;
                appView.lastName        = client.lastName;
                appView.province        = client.province;
                appView.contactNumber   = client.contactNumber;
                appView.emailAdress     = client.emailAdress;
                appView.physicalAddress = client.physicalAddress;
                appView.postalAddress   = client.postalAddress;
                using (var pac = new PackageRepository())
                {
                    appView.packageID = pac.GetById(client.packageID).Name;
                }
                appView.dateSubmitted = client.dateSubmitted;
                appView.status        = client.status;

                var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository();
                var benList          = (from ben in BenefitiaryArepo.GetAll()
                                        where ben.IDNumber == client.IDNumber
                                        select ben).ToList();
                foreach (var ben in benList)
                {
                    appView.beneficiaries.Add(ben);
                }

                var CADocRepo = new ClientApplicationDocumentRepository();
                var docList   = (from x in CADocRepo.GetAll()
                                 where x.applicationID == appID
                                 select x).ToList();
                foreach (var doc in docList)
                {
                    appView.documents.Add(doc);
                }
            }
            catch (Exception ex)
            {
                feedback = "Request unsuccessfull";
            }
            return(appView);
        }
Beispiel #17
0
 public UnitOfWorkAuthorization(AuthorizationContext context) : base(context)
 {
     Claims                 = new ClaimRepository(context);
     ClientApplications     = new ClientApplicationRepository(context);
     ClientApplicationUtils = new ClientApplicationUtilRepository(context);
     RoleClaims             = new RoleClaimRepository(context);
     RoleEntityClaims       = new RoleEntityClaimRepository(context);
     Roles            = new RoleRepository(context);
     UserClaims       = new UserClaimRepository(context);
     UserEntityClaims = new UserEntityClaimRepository(context);
     Users            = new UserRepository(context);
     UserRoles        = new UserRoleRepository(context);
     UserUtils        = new UserUtilRepository(context);
     Applications     = new ApplicationRepository(context);
     ApplicationUsers = new ApplicationUserRepository(context);
 }
Beispiel #18
0
 public void DeclineApplication(int appID, string reason)
 {
     try
     {
         using (var CArepo = new ClientApplicationRepository())
         {
             ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault();
             client.status = "Unsuccessfull : " + reason;
             removeDocs(appID);
             removeBenef(client.IDNumber);
             //send email
         }
     }
     catch (Exception ex)
     {
         feedback = "Request unsuccessfull";
     }
 }
        public List <ClientApplicationDocument> OutstandingDocList(string id)
        {
            if (id == null)
            {
                feedback = "Bad request";
                return(null);
            }
            var ClientArepo = new ClientApplicationRepository();

            ClientApplication client = ClientArepo.Find(x => x.IDNumber == id).SingleOrDefault();

            var CADocRepo = new ClientApplicationDocumentRepository();
            var docList   = (from x in CADocRepo.GetAll()
                             where x.applicationID == client.applicationID
                             select x).ToList();

            return(docList); //list of supporting documents
        }
Beispiel #20
0
 public void ApproveApplication(int appID)
 {
     try
     {
         createPolicyHolder(appID);
         using (var CArepo = new ClientApplicationRepository())
         {
             ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault();
             createBeneficiaries(client.IDNumber);
             createDocuments(appID);
             //removeDocs(appID);
             //removeBenef(client.IDNumber);
         }
     }
     catch (Exception ex)
     {
         feedback = "Request unsuccessfull";
     }
 }
Beispiel #21
0
 public UnitOfWorkIdentity(IdentityContext <TUser, TRole> context) : base(context)
 {
     ClientApplications = new ClientApplicationRepository(context);
 }
        public void addBeneficiary(BeneficiaryViewModel model, string ID)
        {
            var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository();

            if (BenefitiaryArepo.Find(x => x.benIDNumber == model.benIDNumber).SingleOrDefault() == null)
            {
                ClientApplicationBeneficiary ben = new ClientApplicationBeneficiary()
                {
                    benIDNumber  = model.benIDNumber,
                    IDNumber     = ID,
                    firstName    = model.firstName,
                    lastName     = model.lastName,
                    relationship = model.relationship,
                    age          = calcAge(model.benIDNumber)
                };

                var ClientArepo          = new ClientApplicationRepository();
                var CADocRepo            = new ClientApplicationDocumentRepository();
                ClientApplication client = ClientArepo.Find(x => x.IDNumber == ID).SingleOrDefault();
                if (ben.age >= 65)
                {
                    feedback = "We cannot cover a beneficiary of more than 65 years of age";
                    return;
                }
                if (ben.relationship == "Spouse")
                {
                    if (ben.age < 18)
                    {
                        feedback = "Spouse must be at least 18 years of age";
                        return;
                    }
                }

                if (ben.relationship == "Parent" || ben.relationship == "Grandparent" || ben.relationship == "Parent-in-law")
                {
                    if (ben.age < (calcAge(client.IDNumber)))
                    {
                        feedback = "Parent cannot be younger than the Applicant";
                        return;
                    }
                    else if (ben.age == (calcAge(client.IDNumber)))
                    {
                        feedback = "Parent cannot be at the same age as the Applicant";
                        return;
                    }
                    else if (ben.age > calcAge(client.IDNumber) && (ben.age - calcAge(client.IDNumber)) < 13)
                    {
                        feedback = "Parent must be at least 13 years older than the Applicant";
                        return;
                    }
                }
                if (ben.relationship == "Uncle" || ben.relationship == "Aunt")
                {
                    if (ben.age < (calcAge(client.IDNumber)))
                    {
                        feedback = "Uncle or Aunt cannot be younger than the Applicant";
                        return;
                    }
                    else if (ben.age == (calcAge(client.IDNumber)))
                    {
                        feedback = "Uncle or Aunt cannot be at the same age as the Applicant";
                        return;
                    }
                    else if (ben.age > calcAge(client.IDNumber) && (ben.age - calcAge(client.IDNumber)) < 5)
                    {
                        feedback = "Uncle or Aunt must be at least 5 years older than the Applicant";
                        return;
                    }
                }
                if (ben.relationship == "Child" || ben.relationship == "Grandchild")
                {
                    if (ben.age > (calcAge(client.IDNumber)))
                    {
                        feedback = "Child cannot be older than you, " + client.firstName;
                        return;
                    }
                    else if (ben.age == (calcAge(client.IDNumber)))
                    {
                        feedback = "Child cannot be at the same age as the Applicant";
                        return;
                    }
                    else if (ben.age < calcAge(client.IDNumber) && (calcAge(client.IDNumber) - ben.age) < 13)
                    {
                        feedback = "Applicant must be at least 13 years older than the Child";
                        return;
                    }
                }
                BenefitiaryArepo.Insert(ben);

                if (ben.relationship == "Spouse")
                {
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = client.IDNumber,
                        fullname      = client.firstName + " " + client.lastName,
                        documentName  = "Marriage Certificate",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                    ClientApplicationDocument docmnt = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.IDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "ID Document",
                        document      = null,
                    };
                    CADocRepo.Insert(docmnt);
                }
                else if (ben.age >= 21)
                {
                    ClientApplicationDocument docmnt = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.IDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "ID Document",
                        document      = null,
                    };
                    CADocRepo.Insert(docmnt);
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.benIDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "Institutional Proof of Registration | (Full time study)",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                }
                else if (ben.age < 18)
                {
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.benIDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "Birth Certificate",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                }
                else if (ben.age >= 18 && ben.age < 21)
                {
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.benIDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "ID Document",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                }
            }
            else
            {
                feedback = "ID Number already exist!";
            }
        }
 //Add Personal information
 public void CreateApplication(RegisterModel objRegisterModel)
 {
     try
     {
         ClientApplication capp = new ClientApplication
         {
             IDNumber        = objRegisterModel.identityNumber,
             title           = objRegisterModel.title,
             firstName       = objRegisterModel.firstName,
             lastName        = objRegisterModel.lastName,
             province        = objRegisterModel.province,
             contactNumber   = objRegisterModel.contactNumber,
             emailAdress     = objRegisterModel.Email,
             physicalAddress = renderPhysicalAddressSave(objRegisterModel.streetAddress, objRegisterModel.suburb, objRegisterModel.city, objRegisterModel.postalCode.ToString()),
             packageID       = 1,
             dateSubmitted   = DateTime.Now,
             status          = "Awaiting outstanding supporting documents"
         };
         if (objRegisterModel.postalOffice == null)
         {
             capp.postalAddress = renderPhysicalAddressSave(objRegisterModel.streetAddress, objRegisterModel.suburb, objRegisterModel.city, objRegisterModel.postalCode.ToString());
         }
         else
         {
             capp.postalAddress = renderPostalAddressSave(objRegisterModel.postalOffice, objRegisterModel.town, objRegisterModel.boxpostalCode);
         }
         using (var CArepo = new ClientApplicationRepository())
         {
             CArepo.Insert(capp);
             ClientApplication         client = CArepo.Find(x => x.IDNumber == capp.IDNumber).SingleOrDefault();
             ClientApplicationDocument docmnt = new ClientApplicationDocument()
             {
                 applicationID = client.applicationID,
                 IDNumber      = client.IDNumber,
                 fullname      = client.firstName + " " + client.lastName,
                 documentName  = "ID Document",
                 document      = null,
             };
             using (var CADocRepo = new ClientApplicationDocumentRepository())
             {
                 CADocRepo.Insert(docmnt);
             }
             ClientApplicationDocument doc = new ClientApplicationDocument()
             {
                 applicationID = client.applicationID,
                 IDNumber      = client.IDNumber,
                 fullname      = client.firstName + " " + client.lastName,
                 documentName  = "Signed Policy Document",
                 document      = null,
             };
             using (var CADocRepo = new ClientApplicationDocumentRepository())
             {
                 CADocRepo.Insert(doc);
             }
             feedback = "We recieved your Personal Information, please indicate your Beneficiaries.";
             //send email
         }
     }
     catch (Exception ex)
     {
         feedback += " : " + ex;
     }
 }