Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "roleIdentifierID,role")] RoleIdentifier roleIdentifier)
        {
            if (ModelState.IsValid)
            {
                db.RoleIdentifier.Add(roleIdentifier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(roleIdentifier));
        }
        public ActionResult Create([Bind(Include = "recordID,identifier,roleIdentifierID")] RoleIdentifierDetails roleIdentifierDetails)
        {
            if (ModelState.IsValid)
            {
                db.RoleIdentifierDetails.Add(roleIdentifierDetails);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.roleIdentifierID = new SelectList(db.RoleIdentifier, "roleIdentifierID", "role", roleIdentifierDetails.roleIdentifierID);
            return(View(roleIdentifierDetails));
        }
 public ActionResult Create(Fields Fields)
 {
     try
     {
         // TODO: Add insert logic here
         db.Fields.Add(Fields);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public string[] PostSubmission(int id, int ticketID, string[] files)
        {
            var now  = DateTime.Now;
            var date = new DateTime(now.Year, now.Month, now.Day,
                                    now.Hour, now.Minute, now.Second);
            var dbFiles = new List <Files>();

            foreach (var s in files)
            {
                var f = new Files();
                f.File         = s;
                f.CreationDate = date;
                f.User         = db.User.Where(u => u.recordID == id).FirstOrDefault();
                dbFiles.Add(f);
            }
            var submission = new Submission();

            submission.User           = db.User.Where(u => u.recordID == id).FirstOrDefault();
            submission.Ticket         = db.Ticket.Where(t => t.recordID == ticketID).FirstOrDefault();
            submission.submissionDate = date;
            submission.Files          = dbFiles;
            db.Submissions.Add(submission);
            db.SaveChanges();



            return(files);
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int id, StudentUserViewModel studentUser)
        {
            try
            {
                // TODO: Add update logic here
                ModelState.Remove("User.firstName");
                ModelState.Remove("User.lastName");
                ModelState.Remove("User.email");
                ModelState.Remove("User.password");
                ModelState.Remove("User.confirmPassword");
                if (ModelState.IsValid)
                {
                    using (TicketingApp db = new TicketingApp())
                    {
                        db.Configuration.ValidateOnSaveEnabled = false;
                        var user    = db.User.Where(u => u.recordID == studentUser.user.recordID).FirstOrDefault();
                        var student = db.Student.Where(s => s.recordID == studentUser.user.recordID).FirstOrDefault();

                        user.emailNotification = studentUser.user.emailNotification;

                        student.matrikelNumber          = studentUser.student.matrikelNumber;
                        student.beginningSemesterSeason = studentUser.student.beginningSemesterSeason;
                        student.beginningSemesterYear   = studentUser.student.beginningSemesterYear;

                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 6
0
        public ActionResult ResetPassword(User postedUser)
        {
            bool   status  = false;
            string message = "";

            using (TicketingApp db = new TicketingApp())
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                var user = db.User.Where(u => u.recordID == postedUser.recordID).FirstOrDefault();

                if (user != null)
                {
                    user.password        = Crypto.HashPassword(postedUser.password);
                    user.confirmPassword = user.password; // To avoid EntityValidationError
                    db.SaveChanges();
                    status  = true;
                    message = "Your password has been successfully changed.";
                }
                else
                {
                    message = "Something ugly happened behind the scenes. Maybe you can try again later.";
                }
            }
            ViewBag.Message = message;
            ViewBag.Status  = status;
            return(View());
        }
Ejemplo n.º 7
0
        public ActionResult VerifyAccount(string ac, int?id)
        {
            bool status = false;
            User user   = new Models.User();

            using (TicketingApp db = new TicketingApp())
            {
                // To avoid ConfirmPassword does not match issue
                db.Configuration.ValidateOnSaveEnabled = false;
                if (ac != null)
                {
                    user = db.User.Where(u => u.activationCode == new Guid(ac) && u.recordID == id).FirstOrDefault();
                }
                else
                {
                    user = null;
                }

                if (user != null)
                {
                    user.isEmailVerified = true;
                    user.activationCode  = Guid.Empty;
                    db.SaveChanges();
                    status = true;
                }
                else
                {
                    ViewBag.Message = "We cannot find your data in our system. Are you sure you're registered? Or maybe you're already verified";
                }
            }

            ViewBag.Status = status;
            return(View());
        }
Ejemplo n.º 8
0
        public ActionResult Create(string message, string targetURL, List <User> users, string returnURLName, string returnURLController)
        {
            try
            {
                // Let's create a notification
                foreach (var user in users)
                {
                    var notification = new Notification();
                    notification.message = message;
                    notification.url     = targetURL;
                    notification.isRead  = false;

                    using (TicketingApp db = new TicketingApp())
                    {
                        db.Configuration.ValidateOnSaveEnabled = false;
                        var temp = db.User.Where(u => u.recordID == user.recordID).FirstOrDefault();
                        temp.Notification.Add(notification);
                        db.Notification.Add(notification);
                        db.SaveChanges();
                    }

                    if (user.emailNotification == true)
                    {
                        using (TicketingApp db = new TicketingApp())
                        {
                            //Getting system user data
                            var sysUser = db.User.Where(u => u.recordID == 999999).FirstOrDefault();
                            SendNotificationEmail(message, targetURL, user, sysUser);
                        }
                    }
                }

                return(RedirectToAction(returnURLName, returnURLController));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 9
0
        public ActionResult ForgotPassword(string email)
        {
            bool   status  = false;
            string message = "";

            using (TicketingApp db = new TicketingApp())
            {
                var user = db.User.Where(u => u.email == email).FirstOrDefault();

                if (user != null)
                {
                    db.Configuration.ValidateOnSaveEnabled = false;

                    //Giving the user a new GUID
                    user.activationCode = Guid.NewGuid();
                    db.SaveChanges();

                    // Sending Password Reset Email
                    string subject = "Ticketing App - Forgot Password";

                    string body = "<br/><br/>If this wasn't done by you then please ignore this email. " +
                                  "Otherwise Please Click on the link below to reset your password.";
                    string targetUrl = "/User/ResetPassword/";
                    //Getting system user data
                    var sysUser = db.User.Where(u => u.recordID == 999999).FirstOrDefault();
                    SendVerificationEmail(user.recordID, user.email, user.activationCode.ToString(), targetUrl, subject, body, sysUser);
                    status  = true;
                    message = "Please check your email for a reset password link.";
                }
                else
                {
                    message = "We can't seem to find your email. Are you sure it's enterred correctly?";
                }
            }
            ViewBag.Status  = status;
            ViewBag.Message = message;
            return(View());
        }
Ejemplo n.º 10
0
        public ActionResult Notifications()
        {
            if (IsLoggedIn() && IsAuthorized())
            {
                int userID = GetUserID();

                var user = db.User.Where(u => u.recordID == userID).FirstOrDefault();
                var unreadNotifications = db.Notification.Where(n =>
                                                                n.User.recordID == userID &&
                                                                n.isRead == false).ToList();
                var readNotifications = db.Notification.Where(n =>
                                                              n.User.recordID == userID &&
                                                              n.isRead == true).ToList();

                var viewModel = new StudentNotificationViewModel
                {
                    user = user,
                    unreadNotifications = unreadNotifications,
                    readNotifications   = readNotifications
                };

                db.Configuration.ValidateOnSaveEnabled = false;
                foreach (var item in user.Notification)
                {
                    if (item.isRead == false)
                    {
                        item.isRead = true;
                    }
                }
                db.SaveChanges();
                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
        }
Ejemplo n.º 11
0
        public ActionResult ResetPassword(int?id, string ac)
        {
            bool   status  = false;
            string message = null;
            User   user    = new Models.User();

            using (TicketingApp db = new TicketingApp())
            {
                if (ac != null)
                {
                    user = db.User.Where(u => u.activationCode == new Guid(ac) && u.recordID == id).FirstOrDefault();
                }
                else
                {
                    user = null;
                }

                db.Configuration.ValidateOnSaveEnabled = false;
                if (user != null)
                {
                    user.activationCode = Guid.Empty;
                    db.SaveChanges();
                }
                else
                {
                    message = "Maybe you're not authorized to see this page. We're also confused how did you end up here";
                }
            }
            ViewBag.Status  = status;
            ViewBag.Message = message;
            return(View("ResetPassword", new User
            {
                recordID = user.recordID,
                firstName = user.firstName,
                email = user.email
            }));
        }
Ejemplo n.º 12
0
        public ActionResult Create(ProposalIdeaFieldViewModel proposalIdeaFieldViewModel)
        {
            try
            {
                // TODO: Add insert logic here
                using (TicketingApp db = new TicketingApp())
                {
                    proposalIdeaFieldViewModel.AllFields     = db.Fields.ToList();
                    proposalIdeaFieldViewModel.AllSupervisor = db.Supervisor.ToList();

                    int userID = GetUserID();
                    var user   = db.User.Where(u => u.recordID == userID).FirstOrDefault();
                    var idea   = new Idea
                    {
                        title       = proposalIdeaFieldViewModel.proposal.nameOfProject,
                        description = proposalIdeaFieldViewModel.proposal.abstrac,
                        type        = proposalIdeaFieldViewModel.idea.type,
                        field       = proposalIdeaFieldViewModel.idea.field,
                        User        = user
                    };
                    db.Idea.Add(idea);
                    db.SaveChanges();
                    int ideaRecordId = idea.recordID;
                    var ideaCreated  = db.Idea.Where(i => i.recordID == ideaRecordId).FirstOrDefault();
                    proposalIdeaFieldViewModel.proposal.User = user;
                    proposalIdeaFieldViewModel.proposal.Idea = ideaCreated;
                    db.Proposal.Add(proposalIdeaFieldViewModel.proposal);

                    var ticket = new Ticket
                    {
                        title         = proposalIdeaFieldViewModel.proposal.nameOfProject,
                        status        = "Pending",
                        timesRejected = 0,
                        User          = user,
                        Idea          = ideaCreated
                    };
                    db.Ticket.Add(ticket);
                    db.SaveChanges();
                    int ticketRecordId = ticket.recordID;
                    var ticketCreated  = db.Ticket.Where(t => t.recordID == ticketRecordId).FirstOrDefault();

                    string userRole    = GetUserRole();
                    var    contributor = new Contributors
                    {
                        status = "Pending",
                        role   = userRole,
                        User   = user,
                        Ticket = ticketCreated
                    };
                    db.Contributor.Add(contributor);
                    db.SaveChanges();
                    var surperUser = db.User.Where(u => u.recordID == proposalIdeaFieldViewModel.supervisor).FirstOrDefault();



                    var identifier     = surperUser.email;
                    var surperUserRole = db.RoleIdentifier
                                         .Join(db.RoleIdentifierDetails,
                                               roleIdentifier => roleIdentifier.recordID,
                                               roleIdentifierDetails => roleIdentifierDetails.RoleIdentifier.recordID,
                                               (roleIdentifier, roleIdentifierDetails) => new { RoleIdentifier = roleIdentifier, RoleIdentifierDetails = roleIdentifierDetails })
                                         .Where(roleAndDetails => identifier.Contains(roleAndDetails.RoleIdentifierDetails.identifier)).FirstOrDefault();

                    contributor.User = surperUser;
                    contributor.role = surperUserRole.RoleIdentifier.role;
                    db.Contributor.Add(contributor);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                var fields      = db.Fields.ToList();
                var supervisors = db.Supervisor.ToList();
                var viewModel   = new ProposalIdeaFieldViewModel
                {
                    AllFields     = fields,
                    AllSupervisor = supervisors
                };
                return(View(viewModel));
            }
        }
Ejemplo n.º 13
0
        public ActionResult Create(ProposalIdeaFieldViewModel proposalIdeaFieldViewModel, int?id)
        {
            if (IsLoggedIn() && IsAuthorized())
            {
                proposalIdeaFieldViewModel.AllFields     = db.Fields.ToList();
                proposalIdeaFieldViewModel.AllSupervisor = db.Supervisor.ToList();

                int  userID = GetUserID();
                var  user   = db.User.Where(u => u.recordID == userID).FirstOrDefault();
                Idea idea   = null;

                // No need to create a new idea if it already exists i.e. if a Professor has made an idea
                if (id != null)
                {
                    idea = db.Idea.Where(i => i.recordID == id).FirstOrDefault();
                    proposalIdeaFieldViewModel.proposal.nameOfProject = idea.title;
                }
                else
                {
                    idea = new Idea
                    {
                        title       = proposalIdeaFieldViewModel.proposal.nameOfProject,
                        description = proposalIdeaFieldViewModel.proposal.abstrac,
                        type        = proposalIdeaFieldViewModel.idea.type,
                        field       = proposalIdeaFieldViewModel.idea.field,
                        User        = user
                    };
                    db.Idea.Add(idea);
                    db.SaveChanges();
                }

                int ideaRecordId = idea.recordID;
                var ideaCreated  = db.Idea.Where(i => i.recordID == ideaRecordId).FirstOrDefault();
                proposalIdeaFieldViewModel.proposal.User = user;
                proposalIdeaFieldViewModel.proposal.Idea = ideaCreated;
                db.Proposal.Add(proposalIdeaFieldViewModel.proposal);

                db.SaveChanges();

                var      now          = DateTime.Now;
                DateTime date         = DateTime.Now;
                var      ticketStatus = db.TicketStatus.Where(ts => ts.ticketStatus == "Proposal Awaiting Approval").FirstOrDefault();
                var      ticket       = new Ticket
                {
                    title         = proposalIdeaFieldViewModel.proposal.nameOfProject,
                    timesRejected = 0,
                    User          = user,
                    idea          = ideaCreated,
                    creationDate  = date,
                    tickettype    = ideaCreated.type,
                    ticketStatus  = ticketStatus
                };

                db.Ticket.Add(ticket);
                db.SaveChanges();
                int ticketRecordId = ticket.recordID;
                var ticketCreated  = db.Ticket.Where(t => t.recordID == ticketRecordId).FirstOrDefault();

                string userRole    = GetUserRole();
                var    contributor = new Contributors
                {
                    status = "Pending",
                    Role   = userRole,
                    User   = user,
                    Ticket = ticketCreated
                };
                db.Contributors.Add(contributor);
                db.SaveChanges();
                var surperUser = db.User.Where(u => u.recordID == proposalIdeaFieldViewModel.supervisor).FirstOrDefault();

                var identifier     = surperUser.email;
                var surperUserRole = db.RoleIdentifier
                                     .Join(db.RoleIdentifierDetails,
                                           roleIdentifier => roleIdentifier.roleIdentifierID,
                                           roleIdentifierDetails => roleIdentifierDetails.RoleIdentifier.roleIdentifierID,
                                           (roleIdentifier, roleIdentifierDetails) => new { RoleIdentifier = roleIdentifier, RoleIdentifierDetails = roleIdentifierDetails })
                                     .Where(roleAndDetails => identifier.Contains(roleAndDetails.RoleIdentifierDetails.identifier)).FirstOrDefault();

                contributor.User = surperUser;
                contributor.Role = surperUserRole.RoleIdentifier.role;
                db.Contributors.Add(contributor);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
        }
Ejemplo n.º 14
0
        public ActionResult Create(ProposalIdeaFieldViewModel proposalIdeaFieldViewModel)
        {
            try
            {
                // TODO: Add insert logic here
                using (TicketingApp db = new TicketingApp())
                {
                    proposalIdeaFieldViewModel.AllFields     = db.Fields.ToList();
                    proposalIdeaFieldViewModel.AllSupervisor = db.Supervisor.ToList();

                    int userID1 = GetUserID();
                    var user1   = db.User.Where(u => u.recordID == userID1).FirstOrDefault();
                    var idea1   = new Idea
                    {
                        title       = proposalIdeaFieldViewModel.proposal.nameOfProject,
                        description = proposalIdeaFieldViewModel.proposal.abstrac,
                        type        = proposalIdeaFieldViewModel.idea.type,
                        field       = proposalIdeaFieldViewModel.idea.field,
                        User        = user1
                    };
                    db.Idea.Add(idea1);
                    db.SaveChanges();
                    int ideaRecordId = idea1.recordID;
                    var ideaCreated  = db.Idea.Where(i => i.recordID == ideaRecordId).FirstOrDefault();
                    proposalIdeaFieldViewModel.proposal.User = user1;
                    proposalIdeaFieldViewModel.proposal.Idea = ideaCreated;
                    db.Proposal.Add(proposalIdeaFieldViewModel.proposal);

                    var ticket1 = new Ticket
                    {
                        title         = proposalIdeaFieldViewModel.proposal.nameOfProject,
                        status        = "Pending",
                        timesRejected = 0,
                        User          = user1,
                        Idea          = ideaCreated
                    };
                    db.Ticket.Add(ticket1);
                    db.SaveChanges();
                    int ticketRecordId = ticket1.recordID;
                    var ticketCreated  = db.Ticket.Where(t => t.recordID == ticketRecordId).FirstOrDefault();

                    string userRole    = GetUserRole();
                    var    contributor = new Contributors
                    {
                        status = "Pending",
                        Role   = userRole,
                        User   = user1,
                        Ticket = ticketCreated
                    };
                    db.Contributors.Add(contributor);
                    db.SaveChanges();
                    var surperUser = db.User.Where(u => u.recordID == proposalIdeaFieldViewModel.supervisor).FirstOrDefault();



                    var identifier     = surperUser.email;
                    var surperUserRole = db.RoleIdentifier
                                         .Join(db.RoleIdentifierDetails,
                                               roleIdentifier => roleIdentifier.recordID,
                                               roleIdentifierDetails => roleIdentifierDetails.RoleIdentifier.recordID,
                                               (roleIdentifier, roleIdentifierDetails) => new { RoleIdentifier = roleIdentifier, RoleIdentifierDetails = roleIdentifierDetails })
                                         .Where(roleAndDetails => identifier.Contains(roleAndDetails.RoleIdentifierDetails.identifier)).FirstOrDefault();

                    contributor.User = surperUser;
                    contributor.Role = surperUserRole.RoleIdentifier.role;
                    db.Contributors.Add(contributor);
                    db.SaveChanges();
                }
                int userID = GetUserID();

                var user     = db.User.Where(u => u.recordID == userID).FirstOrDefault();
                var student  = db.Student.Where(s => s.recordID == userID).FirstOrDefault();
                var ticket   = db.Ticket.Where(t => t.Contributors.Any(c => c.User.recordID == userID)).FirstOrDefault();
                var idea     = db.Idea.Where(i => i.User.recordID != userID).ToList();
                var proposal = db.Proposal.Where(p => p.User.recordID == userID).ToList();

                var proposalUser = new ProposalUserViewModel
                {
                    user           = user,
                    student        = student,
                    ticket         = ticket,
                    availableIdeas = idea,
                    proposals      = proposal
                };
                return(View("Index", proposalUser));
            }
            catch
            {
            }
        }
Ejemplo n.º 15
0
        public ActionResult Edit(int id, SupervisorUserFieldViewModel supervisorUser)
        {
            try
            {
                // TODO: Add update logic here
                ModelState.Remove("User.firstName");
                ModelState.Remove("User.lastName");
                ModelState.Remove("User.email");
                ModelState.Remove("User.password");
                ModelState.Remove("User.confirmPassword");
                if (ModelState.IsValid)
                {
                    db.Configuration.ValidateOnSaveEnabled = false;
                    var supervisor = db.Supervisor.Where(s => s.recordID == supervisorUser.supervisor.recordID).FirstOrDefault();
                    var user       = db.User.Where(u => u.recordID == supervisorUser.user.recordID).FirstOrDefault();
                    var fields     = new List <Fields>();

                    user.emailNotification = supervisorUser.user.emailNotification;
                    if (supervisorUser.selectedFields != null)
                    {
                        foreach (int item in supervisorUser.selectedFields)
                        {
                            fields.Add(db.Fields.Where(f => f.recordID == item).FirstOrDefault());
                        }
                        supervisor.Fields.Clear();
                        foreach (var item in fields)
                        {
                            supervisor.Fields.Add(item);
                        }
                    }

                    if (supervisorUser.supervisor.daysForReport != null)
                    {
                        supervisor.daysForReport = supervisorUser.supervisor.daysForReport;
                    }

                    db.SaveChanges();

                    //Checking if scheduler is needed
                    if (supervisor.daysForReport != "0")
                    {
                        //Checking for Quartz Scheduler
                        var scheduler = HttpContext.Application["Scheduler"] as IScheduler;

                        //Checking if the job is already added in the scheduler
                        JobKey jobKey    = JobKey.Create("report-job", "report-job-group");
                        var    reportJob = scheduler.GetJobDetail(jobKey);

                        if (reportJob == null)
                        {
                            //Preparing data
                            string subject = "Your Ticketing Report";
                            var    sysUser = db.User.Where(u => u.recordID == 999999).FirstOrDefault();

                            IJobDetail job = JobBuilder.Create <ReportJob>()
                                             .WithIdentity("report-job", "report-job-group")
                                             .Build();
                            job.JobDataMap["subject"] = subject;
                            job.JobDataMap["user"]    = user;
                            job.JobDataMap["sysUser"] = sysUser;

                            ITrigger trigger = TriggerBuilder.Create()
                                               .WithSimpleSchedule(s => s.WithIntervalInSeconds(60).RepeatForever())
                                               .Build();

                            scheduler.ScheduleJob(job, trigger);
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 16
0
        public ActionResult Register(User user)
        {
            bool   status     = false;
            string message    = "";
            string roleOfUser = "";

            if (ModelState.IsValid)
            {
                //Check if Email already exists
                var emailExists = DoesEmailExist(user.email);

                if (emailExists)
                {
                    ModelState.AddModelError("EmailExists", "The email you provided already exists");
                    return(View(user));
                }

                //Generating Activation Code
                user.activationCode = Guid.NewGuid();

                //Hashing the Password
                user.password        = Crypto.HashPassword(user.password);
                user.confirmPassword = user.password; // To avoid EntityValidationError

                user.isEmailVerified   = false;
                user.emailNotification = true;

                using (TicketingApp db = new TicketingApp())
                {
                    //Checking the role of the user registering
                    MailAddress address    = new MailAddress(user.email);
                    string      identifier = address.Host;

                    var role = db.RoleIdentifier
                               .Join(db.RoleIdentifierDetails,
                                     roleIdentifier => roleIdentifier.roleIdentifierID,
                                     roleIdentifierDetails => roleIdentifierDetails.RoleIdentifier.roleIdentifierID,
                                     (roleIdentifier, roleIdentifierDetails) => new { RoleIdentifier = roleIdentifier, RoleIdentifierDetails = roleIdentifierDetails })
                               .Where(roleAndDetails => roleAndDetails.RoleIdentifierDetails.identifier == identifier).FirstOrDefault();
                    if (role != null)
                    {
                        db.User.Add(user);
                        if (role.RoleIdentifier.role == "Student")
                        {
                            Student student = new Student();
                            student.recordID = user.recordID;
                            student.userType = "Student";
                            db.Student.Add(student);
                            db.SaveChanges();
                            roleOfUser = "******";
                        }
                        else if (role.RoleIdentifier.role == "Supervisor")
                        {
                            Supervisor supervisor = new Supervisor();
                            supervisor.recordID = user.recordID;
                            supervisor.userType = "Supervisor";
                            db.Supervisor.Add(supervisor);
                            db.SaveChanges();
                            roleOfUser = "******";
                        }

                        // Sending Activation Email
                        string subject = "Your account is successfully created";

                        string body = "<br/><br/>So you want to join the ticketing world? One more step and you're done." +
                                      " Please Click on the link below to verify your account.";
                        string targetUrl = "/User/VerifyAccount/";
                        //Getting system user data
                        var sysUser = db.User.Where(u => u.recordID == 999999).FirstOrDefault();
                        SendVerificationEmail(user.recordID, user.email, user.activationCode.ToString(), targetUrl, subject, body, sysUser);
                        status  = true;
                        message = "Your account is now created. Please check your email for an activation code.";
                    }
                    else
                    {
                        message = "Your email maybe valid but seems like you're not recognized by our system. Please check if it's correct.";
                    }
                }
                ModelState.Clear();
            }
            else
            {
                message = "Something weird happened. Developers, could you check the Register Action in your controller?";
            }

            ViewBag.role    = roleOfUser;
            ViewBag.message = message;
            ViewBag.status  = status;

            return(View(user));
        }