Beispiel #1
0
        public ActionResult Approve(int?id)
        {
            Institution institution = db.Institutions.Where(p => p.InstitutionID == id).FirstOrDefault();

            if (institution.Status == "Approved" || institution.Status == "Rejected")
            {
                TempData["AlertMessage"] = "Th application has already been Rejected/Approved";
                return(RedirectToAction("AdminIndex"));
            }
            else
            {
                ApprovedInstitution approvedInstitution = new ApprovedInstitution();
                approvedInstitution.InstitutionID = institution.InstitutionID;
                approvedInstitution.FullName      = institution.FullName;

                approvedInstitution.Email = institution.Email;

                approvedInstitution.Phone     = institution.Phone;
                approvedInstitution.Type      = institution.Type;
                approvedInstitution.FileName  = institution.FileName;
                approvedInstitution.UserPhoto = institution.UserPhoto;

                approvedInstitution.Status = "Approved";
                db.ApprovedInstitutions.Add(approvedInstitution);
                db.SaveChanges();


                //Send An Email After Approval with Activated User Roles and Moodle Credential
                var mailTo = new List <MailAddress>();
                mailTo.Add(new MailAddress(institution.Email, institution.FullName));
                var body = $"Hello {institution.FullName}, Congratulations. We are glad to inform you that your application has been approved. You can now procced to adding your building details. You are required to pay the Subscription Fee in order for your building to be active to the Tenants <br/> Regards,<br/><br/> HomeLink <br/> .";

                //Accommodation.Services.Implementation.EmailService emailService = new Accommodation.Services.Implementation.EmailService();
                BackEnd.DataManager.EmailService emailService = new BackEnd.DataManager.EmailService();
                emailService.SendEmail(new EmailContent()
                {
                    mailTo          = mailTo,
                    mailCc          = new List <MailAddress>(),
                    mailSubject     = "Application Statement | Ref No.:" + institution.InstitutionID,
                    mailBody        = body,
                    mailFooter      = "<br/> Many Thanks, <br/> <b>Alliance</b>",
                    mailPriority    = MailPriority.High,
                    mailAttachments = new List <Attachment>()
                });


                db.Institutions.Remove(institution);
                db.SaveChanges();

                //userManager.AddToRole(institution.UserId, "Institution");
                TempData["AlertMessage"] = $"{institution.FullName} has been successfully approved";

                return(RedirectToAction("Index"));
            }
        }
Beispiel #2
0
        public ActionResult Approve(int?id)
        {
            TempData["Message"] = "Your deposit " + id + "has been Saved Successfully ";
            Deposit     deposit       = db.Deposits.Where(p => p.DepositID == id).FirstOrDefault();
            int         applicationID = deposit.ApplicationID;
            Application application   = db.Applications.Where(a => a.ApplicationID == applicationID).FirstOrDefault();

            if (deposit.Status == "Approved" || deposit.Status == "Rejected")
            {
                TempData["AlertMessage"] = "Th application has already been Rejected/Approved";
                return(RedirectToAction("AdminIndex"));
            }
            else
            {
                ApprovedDeposit approvedDeposit = new ApprovedDeposit();
                approvedDeposit.ApprovedDepositID = deposit.DepositID;
                approvedDeposit.AccountNumber     = deposit.AccountNumber;
                approvedDeposit.DepositAmount     = deposit.DepositAmount;
                approvedDeposit.DepositDate       = deposit.DepositDate;
                approvedDeposit.AccountType       = deposit.AccountType;
                approvedDeposit.FileContent       = deposit.FileContent;
                approvedDeposit.FileName          = deposit.FileName;
                approvedDeposit.ID            = deposit.ID;
                approvedDeposit.ApplicationID = deposit.ApplicationID;
                approvedDeposit.UserEmail     = deposit.UserEmail;


                application.PaymentStatus   = "Approved";
                application.Status          = "Active";
                application.StartDate       = DateTime.Parse(DateTime.Now.ToString("yyy.MM.dd")).Date;
                application.ExpiryDateDate  = DateTime.Parse(DateTime.Now.ToString("yyy.MM.dd")).Date.AddMonths(1);
                db.Entry(application).State = EntityState.Modified;
                db.SaveChanges();


                approvedDeposit.Status = "Approved";
                db.ApprovedDeposits.Add(approvedDeposit);
                db.SaveChanges();


                //Send An Email After Approval with Activated User Roles and Moodle Credential
                var mailTo = new List <MailAddress>();
                mailTo.Add(new MailAddress(deposit.UserEmail, deposit.DepositAmount.ToString()));
                var body = $"Hello {deposit.UserEmail}, Congratulations. We are glad to inform you that your application has been approved. You can now procced to adding your building details. You are required to pay the Subscription Fee in order for your building to be active to the Tenants <br/> Regards,<br/><br/> HomeLink <br/> .";

                //Accommodation.Services.Implementation.EmailService emailService = new Accommodation.Services.Implementation.EmailService();
                BackEnd.DataManager.EmailService emailService = new BackEnd.DataManager.EmailService();
                emailService.SendEmail(new EmailContent()
                {
                    mailTo          = mailTo,
                    mailCc          = new List <MailAddress>(),
                    mailSubject     = "Application Statement | Ref No.:" + deposit.DepositTraceCode,
                    mailBody        = body,
                    mailFooter      = "<br/> Many Thanks, <br/> <b>Alliance</b>",
                    mailPriority    = MailPriority.High,
                    mailAttachments = new List <Attachment>()
                });


                db.Deposits.Remove(deposit);
                db.SaveChanges();

                //userManager.AddToRole(institution.UserId, "Institution");
                TempData["AlertMessage"] = $"{deposit.UserEmail} has been successfully approved";

                return(RedirectToAction("Index"));
            }
        }