Esempio n. 1
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";
            }
        }
        public void AddServiceRep(ServiceRepresentativeView objServRepView)
        {
            using (var servreprepo = new ServiceRepresentativeRepository())
            {
                var newuser = new ApplicationUser()
                {
                    Id           = objServRepView.IDNumber,
                    UserName     = objServRepView.IDNumber,
                    FullName     = objServRepView.Fullname,
                    Email        = objServRepView.Email,
                    PasswordHash = UserManager.PasswordHasher.HashPassword(genePassword(objServRepView.IDNumber))
                };

                var result = UserManager.CreateAsync(newuser, genePassword(objServRepView.IDNumber));

                var servrep = new ServiceRepresentative
                {
                    ServiceRepIdNo = geneServRepNo(objServRepView.IDNumber, objServRepView.Fullname),
                    IDNumber       = objServRepView.IDNumber,
                    Fullname       = objServRepView.Fullname,
                    Email          = objServRepView.Email,
                    ContactNo      = objServRepView.ContactNo,
                    AppUserId      = newuser.Id
                };

                servreprepo.Insert(servrep);

                rb.AddUserToRole(objServRepView.IDNumber, "Service Representative");
            }
        }
Esempio n. 3
0
        public void Restore(string id)
        {
            var ArchiveRep = new ServiceRepresentativeRepository();
            var ar         = new ArchiveServiceRepresentativeRepository();

            ArchiveServiceRepresentative arch = ar.GetById(id);

            if (arch != null)
            {
                var mm = new ServiceRepresentative()
                {
                    ServiceRepIdNo = arch.ServiceRepIdNo,
                    IDNumber       = arch.IDNumber,
                    Fullname       = arch.Fullname,
                    Email          = arch.Email,
                    ContactNo      = arch.ContactNo
                };

                var newuser = new ApplicationUser()
                {
                    Id           = mm.IDNumber,
                    UserName     = mm.IDNumber,
                    FullName     = mm.Fullname,
                    Email        = mm.Email,
                    PasswordHash = UserManager.PasswordHasher.HashPassword(genePassword(mm.IDNumber))
                };

                var result = UserManager.CreateAsync(
                    newuser, genePassword(mm.IDNumber));

                ar.Delete(arch);
                ArchiveRep.Insert(mm);

                rb.AddUserToRole(newuser.Id, "Service Representative");
            }
        }