public async Task <IActionResult> RegisterApplication(ApplicationViewModel model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (User.IsInRole("tecnico") || User.IsInRole("tecnico_admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Application app = model.Application;

            app.IdProgramNavigation = _context.Program.Where(p => p.IdProgram == 1).FirstOrDefault();  //ERASMUS MUDAR PROX FASE
            app.IdStateNavigation   = _context.State.Where(s => s.Description == "Em Avaliação").FirstOrDefault();
            app.IdStudentNavigation = GetStudentById(GetCurrentUserID());
            app.ApplicationDate     = DateTime.Now;
            app.SignedAppFile       = await CreateSignedApplication(model);

            _context.Application.Add(model.Application);
            _context.SaveChanges();

            AddApplicationNotification();

            return(RedirectToAction("MyApplications", "Application"));
        }
Example #2
0
        public bool InsertPendingAccount(string strEmail, EnumAccountType enUserType, int intIsAdmin)
        {
            using (var context = new CIMOB_IPS_DBContext(new DbContextOptions <CIMOB_IPS_DBContext>()))
            {
                if (context.PendingAccount.Any(p => p.Email == strEmail))
                {
                    return(false);
                }

                Guid guid = Guid.NewGuid();

                PendingAccount pendingAccount = new PendingAccount {
                    Email = strEmail, Guid = guid.ToString(), IsAdmin = Convert.ToBoolean(intIsAdmin)
                };

                context.Add(pendingAccount);
                context.SaveChanges();

                if (enUserType == EnumAccountType.STUDENT)
                {
                    SendEmailToStudent(strEmail, guid.ToString());
                }
                else
                {
                    SendEmailToTec(strEmail, guid.ToString());
                }

                return(true);
            }
        }