public ActionResult AddRole(AspNetRole role)
        {
            role.Id = ReferenceFactory.GenerateReference(role.Name, 9);
            ent.AspNetRoles.Add(role);
            ent.SaveChanges();

            return(RedirectToAction("DisplayRoles"));
        }
        public ActionResult CreateApplication(CreateApplicationViewModel app)
        {
            if (ModelState.IsValid)
            {
                int dateId = WebSettings.getCurrentDate();

                SinisianDatabase sinDb = srch.FindInSinisian(app.FirstName, app.MiddleName, app.LastName);

                string referenceNum = ReferenceFactory.GenerateReference(app.FirstName + app.MiddleName + app.LastName);

                if (sinDb == null)
                {
                    TempData["errorMsg"] = "Sorry we cannot find your identity.";
                    return(RedirectToAction("CreateApplication", app));
                }

                int count = ent.Applications.Where(m => m.SinId == sinDb.SinId && m.DSetIdApplied == dateId).Count();

                if (count >= 1)
                {
                    TempData["errorMsg"] = "You already have an application. You can check your status from the \"Application Status\" in the navbar.";
                    return(RedirectToAction("CreateApplication"));
                }

                /**
                 * isa, if officer na siya hindi na siya pwede pang mag aaply pa para maging officer
                 */

                Application application = new Application()
                {
                    ATypeId       = int.Parse(app.ApplicationType),
                    ASTypId       = ent.ApplicationStatusTypes.Where(m => m.Name.ToLower() == "queue").Select(m => m.ASTypId).FirstOrDefault(),
                    DSetIdApplied = dateId,
                    RerenceNum    = referenceNum,
                    SinId         = sinDb.SinId,
                };

                ent.Applications.Add(application);
                ent.SaveChanges();

                Mailer.SendEmail(new IdentityMessage()
                {
                    Subject = "Application Reference Number", Body = "<b>" + referenceNum + "</b> is your reference number to your application.<br><br>Please click this link to check application status.<br><br><br><br><b>Sincerely,</b><br>Flores De Mayo President.<br><br><br><br>If you have any concern please send a feedback to us at <a href=\"\">this link.</a>", Destination = app.Email
                });
            }
            else
            {
            }

            return(RedirectToAction("CreateApplication"));
        }
Exemplo n.º 3
0
        public ActionResult CreateAlayan(CreateAlayanViewModel alayanVM)
        {
            if (ModelState.IsValid)
            {
                SinisianDatabase sinDb = srch.FindInSinisian(alayanVM.FirstName, alayanVM.MiddleName, alayanVM.LastName);

                string referenceNum = ReferenceFactory.GenerateReference(alayanVM.FirstName + alayanVM.MiddleName + alayanVM.LastName);
                int    dateId       = WebSettings.getCurrentDate();

                if (sinDb == null)
                {
                    TempData["errorMsg"] = "Sorry we cannot find your identity.";
                    return(RedirectToAction("CreateAlayan"));
                }

                int count = ent.Alayans.Where(m => m.SinId == sinDb.SinId && m.DSetIdApplied == dateId).Count();

                if (count >= 1)
                {
                    TempData["errorMsg"] = "You already have an application. You can check your status from the \"Application Status\" in the navbar.";
                    return(RedirectToAction("CreateAlayan"));
                }

                Alayan alayan = new Alayan()
                {
                    ADatId        = alayanVM.AlayDate,
                    ATypId        = alayanVM.AlayType,
                    DSetIdApplied = dateId,
                    Reference     = referenceNum,
                    SinId         = sinDb.SinId
                };

                ent.Alayans.Add(alayan);
                ent.SaveChanges();

                Mailer.SendEmail(new IdentityMessage()
                {
                    Subject = "Alayan Schedule Reference Number", Body = "<b>" + referenceNum + "</b> is your reference number to your alayan schedule.<br><br>Please click this link to check the summary.<br><br><br><br><b>Sincerely,</b><br>Flores De Mayo President.<br><br><br><br>If you have any concern please send a feedback to us at <a href=\"\">this link.</a>", Destination = alayanVM.Email
                });

                return(RedirectToAction("CreateAlayan"));
            }
            else
            {
                TempData["errorMsg"] = "Sorry, please try again.";
                return(RedirectToAction("CreateAlayan"));
            }
        }