public ActionResult Create([Bind(Include = "Id,Name,CreateBy,CreateDate,ModifyBy,ModifyDate")] Gender gender)
        {
            if (ModelState.IsValid)
            {
                db.Genders.Add(gender);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gender));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "Id,Name,CreateBy,CreateDate,ModifyBy,ModifyDate")] NominatingBodyCategory nominatingBodyCategory)
        {
            if (ModelState.IsValid)
            {
                db.NominatingBodyCategories.Add(nominatingBodyCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nominatingBodyCategory));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "Id,Name,Abbreviation,Quantity,OrderBy,CreateBy,CreateDate,ModifyBy,ModifyDate")] Medal medal)
        {
            if (ModelState.IsValid)
            {
                db.Medals.Add(medal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medal));
        }
        public ActionResult Create([Bind(Include = "Id,Name,CreateBy,CreateDate,ModifyBy,ModifyDate")] AttachmentType attachmentType)
        {
            if (ModelState.IsValid)
            {
                db.AttachmentTypes.Add(attachmentType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(attachmentType));
        }
        public ActionResult Create([Bind(Include = "Id,CountyName,CountyCode,CreateBy,CreateDate,ModifyBy,ModifyDate")] County county)
        {
            if (ModelState.IsValid)
            {
                db.Counties.Add(county);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(county));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "Id,Name,CreateBy,CreateDate,ModifyBy,ModifyDate")] AcademicQualification academicQualification)
        {
            if (ModelState.IsValid)
            {
                db.AcademicQualifications.Add(academicQualification);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(academicQualification));
        }
示例#7
0
 public ActionResult Create(ApprovalStages approvalStages)
 {
     if (ModelState.IsValid)
     {
         db.ApprovalStages.Add(approvalStages);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoleId = new SelectList(db.Roles, "Id", "Name");
     return(View(approvalStages));
 }
        public ActionResult Create([Bind(Include = "Id,SerialNo,Title,Name,IdNumber,Medal,Rank,ConfirementDate,Nationality,CreateBy,CreateDate,ModifyBy,ModifyDate")] HonorRole honorRole)
        {
            if (ModelState.IsValid)
            {
                db.HonorRoles.Add(honorRole);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(honorRole));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Month,Year,NominationDate,CreateBy,CreateDate,ModifyBy,ModifyDate")] NominationPeriod nominationPeriod)
        {
            if (ModelState.IsValid)
            {
                db.NominationPeriods.Add(nominationPeriod);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nominationPeriod));
        }
示例#10
0
        public ActionResult Create([Bind(Include = "Id,Name,CreateBy,CreateDate,ModifyBy,ModifyDate")] Occupation occupation)
        {
            if (ModelState.IsValid)
            {
                db.Occupations.Add(occupation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(occupation));
        }
示例#11
0
        public ActionResult Create([Bind(Include = "Id,WardName,WardCode,SubCountyId,CreateBy,CreateDate,ModifyBy,ModifyDate")] Ward ward)
        {
            if (ModelState.IsValid)
            {
                db.Wards.Add(ward);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SubCountyId = new SelectList(db.SubCounties, "Id", "SubCountyName", ward.SubCountyId);
            return(View(ward));
        }
示例#12
0
        public ActionResult Create([Bind(Include = "Id,SubCountyName,SubCountyCode,CountyId,CreateBy,CreateDate,ModifyBy,ModifyDate")] SubCounty subCounty)
        {
            if (ModelState.IsValid)
            {
                db.SubCounties.Add(subCounty);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountyId = new SelectList(db.Counties, "Id", "CountyName", subCounty.CountyId);
            return(View(subCounty));
        }
        public ActionResult Create([Bind(Include = "Id,PositionHeld,Project,Role,Achivement,StartDate,EndDate,NominationId,CreateBy,CreateDate,ModifyBy,ModifyDate")] CitationAchievement citationAchievement)
        {
            if (ModelState.IsValid)
            {
                db.CitationAchievements.Add(citationAchievement);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NominationId = new SelectList(db.Nominations, "Id", "IdNumber", citationAchievement.NominationId);
            return(View(citationAchievement));
        }
示例#14
0
        public ActionResult Create([Bind(Include = "Id,RecognizingInstitution,AchievementTitle,Award,AwardDate,NominationId,CreateBy,CreateDate,ModifyBy,ModifyDate")] PreviousRecognition previousRecognition)
        {
            if (ModelState.IsValid)
            {
                db.PreviousRecognitions.Add(previousRecognition);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NominationId = new SelectList(db.Nominations, "Id", "IdNumber", previousRecognition.NominationId);
            return(View(previousRecognition));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Order,NominatingBodyCategoryId,CreateBy,CreateDate,ModifyBy,ModifyDate")] NominatingBody nominatingBody)
        {
            if (ModelState.IsValid)
            {
                db.NominatingBodies.Add(nominatingBody);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NominatingBodyCategoryId = new SelectList(db.NominatingBodyCategories, "Id", "Name", nominatingBody.NominatingBodyCategoryId);
            return(View(nominatingBody));
        }
        public ActionResult Create(UserDetailsViewModel model)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            model.RegisterViewModel.Email = model.UserDetails.EmailAddress;
            var userInDb = UserManager.FindByName(model.RegisterViewModel.UserName);

            if (ModelState.IsValid && userInDb == null)
            {
                userInDb          = new ApplicationUser();
                userInDb.UserName = model.RegisterViewModel.UserName;
                userInDb.Email    = model.UserDetails.EmailAddress;
                UserManager.Create(userInDb, model.RegisterViewModel.Password);

                var rolename = roleManager.FindById(model.RoleId);

                var userInRole = UserManager.IsInRole(userInDb.Id, rolename.Name);
                if (!userInRole)
                {
                    UserManager.AddToRole(userInDb.Id, rolename.Name);
                }

                model.UserDetails.NominatingBodyId = model.NominatingBodyId;
                model.UserDetails.PostalCodeId     = model.PostalCodeId;
                model.UserDetails.UserId           = userInDb.Id;
                db.UserDetails.Add(model.UserDetails);
                db.SaveChanges();
                TempData["UserMessage"] = new MessageVM()
                {
                    CssClassName = "alert-success", Title = "Success!", Message = "User added successfully."
                };
                return(RedirectToAction("Index"));
            }
            else
            {
                var validationErrors = ModelState.Values.Where(E => E.Errors.Count > 0)
                                       .SelectMany(E => E.Errors)
                                       .Select(E => E.ErrorMessage)
                                       .ToList();
            }

            ViewBag.RoleId           = new SelectList(db.Roles, "Id", "Name");
            ViewBag.NominatingBodyId = new SelectList(db.NominatingBodies, "Id", "Name", model.UserDetails.NominatingBodyId);
            ViewBag.PostalCodeId     = new SelectList(db.PostalCodes, "Id", "Town");
            TempData["UserMessage"]  = new MessageVM()
            {
                CssClassName = "alert-error", Title = "Error!", Message = "UserName or Email already exists in the database."
            };
            return(View(model));
        }
        public ActionResult Create([Bind(Include = "Id,AttachmentUrl,NominationId,AttachmentTypeId,CreateBy,CreateDate,ModifyBy,ModifyDate")] NominationAttachment nominationAttachment)
        {
            if (ModelState.IsValid)
            {
                db.NominationAttachments.Add(nominationAttachment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AttachmentTypeId = new SelectList(db.AttachmentTypes, "Id", "Name", nominationAttachment.AttachmentTypeId);
            ViewBag.NominationId     = new SelectList(db.Nominations, "Id", "IdNumber", nominationAttachment.NominationId);
            return(View(nominationAttachment));
        }
示例#18
0
        public static void InsertWard()
        {
            using (NHAMISContext dbcontext = new NHAMISContext())
            {
                string path = HttpContext.Current.Server.MapPath(@"~/Models/Initialisation/Wards.txt");

                string[] Wards = File.ReadAllLines(path);

                foreach (string WardLine in Wards)
                {
                    string wardName = WardLine.Split('=')[0];

                    string subcountyName = WardLine.Split('=')[1];

                    var subcountyId = dbcontext.Subcounties.Where(n => n.SubCountyName == subcountyName).Select(c => c.Id).FirstOrDefault();

                    Subcounty subcounty = dbcontext.Subcounties.Find(subcountyId);

                    Ward Ward = new Ward()
                    {
                        WardName = wardName, Subcounty = subcounty
                    };

                    dbcontext.Wards.Add(Ward);
                }
                dbcontext.SaveChanges();
            }
        }
示例#19
0
        public static void InsertConstituency()
        {
            using (NHAMISContext dbcontext = new NHAMISContext())
            {
                string path = HttpContext.Current.Server.MapPath(@"~/Models/Initialisation/Constituencies.txt");

                string[] Constituencies = File.ReadAllLines(path);

                foreach (string ConstituencyLine in Constituencies)
                {
                    string subcountyName = ConstituencyLine.Split('=')[0];

                    string countyName = ConstituencyLine.Split('=')[1];

                    var CountyId = dbcontext.Counties.Where(n => n.CountyName == countyName).Select(f => f.Id).FirstOrDefault();

                    County County = dbcontext.Counties.Find(CountyId);

                    Subcounty subcounty = new Subcounty()
                    {
                        SubCountyName = subcountyName, County = County
                    };

                    dbcontext.Subcounties.Add(subcounty);
                }
                dbcontext.SaveChanges();
            }
        }
 public ActionResult Edit([Bind(Include = "Id,IdNumber,Surname,OtherNames,DateOfBirth,Nationality,CountyOfBirth,Address,EmailAddress,MobileNumber,Location,SubLocation,Village,Occupation,PublicServiceRecords,Status,WardId,SalutationId,NominationPeriodId,NominationBodyId,CreateBy,CreateDate,ModifyBy,ModifyDate")] Nomination nomination)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nomination).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NominationBodyId        = new SelectList(db.NominatingBodies, "Id", "Name");
     ViewBag.NominationPeriodId      = new SelectList(db.NominationPeriods, "Id", "Name");
     ViewBag.SalutationId            = new SelectList(db.Salutations, "Id", "Name");
     ViewBag.CountryId               = new SelectList(db.Countries, "Id", "Name");
     ViewBag.CountyId                = new SelectList(db.Counties, "Id", "CountyName");
     ViewBag.CountyOfBirthId         = new SelectList(db.Counties, "CountyName", "CountyName");
     ViewBag.SubCountyId             = new SelectList(db.SubCounties, "Id", "SubCountyName");
     ViewBag.WardId                  = new SelectList(db.Wards, "Id", "WardName");
     ViewBag.MedalId                 = new SelectList(db.Medals.OrderBy(o => o.OrderBy), "Id", "Name");
     ViewBag.AcademicQualificationId = new SelectList(db.AcademicQualifications, "Id", "Name");
     ViewBag.OccupationId            = new SelectList(db.Occupations, "Id", "Name");
     ViewBag.GenderId                = new SelectList(db.Genders, "Id", "Name");
     return(View(nomination));
 }
示例#21
0
        public static void InsertCounty()
        {
            using (NHAMISContext dbcontext = new NHAMISContext())
            {
                string path = HttpContext.Current.Server.MapPath(@"~/Models/Initialisation/Counties.txt");

                string[] Counties = File.ReadAllLines(path);

                foreach (string CountyLine in Counties)
                {
                    string countyName = CountyLine;
                    County County     = new County()
                    {
                        CountyName = countyName
                    };

                    dbcontext.Counties.Add(County);
                }
                dbcontext.SaveChanges();
            }
        }
示例#22
0
        public static void InsertPostalCodes()
        {
            using (NHAMISContext dbcontext = new NHAMISContext())
            {
                string path = HttpContext.Current.Server.MapPath(@"~/Models/Initialisation/PostalCodesKenya.txt");

                string[] postalCodesFile = File.ReadAllLines(path);

                foreach (string postalCodeLine in postalCodesFile)
                {
                    string postalNameText = (postalCodeLine.Split('-')[0]).ToUpper();
                    int    postalCodeText = Int32.Parse(postalCodeLine.Split('-')[1]);

                    PostalCode postalCode = new PostalCode()
                    {
                        Code = postalCodeText, Town = postalNameText
                    };
                    dbcontext.PostalCodes.Add(postalCode);
                }
                dbcontext.SaveChanges();
            }
        }
示例#23
0
        private void CreateRolesandUsers()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            NHAMISContext        db      = new NHAMISContext();

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            if (!roleManager.RoleExists("Admin"))
            {
                var role = new IdentityRole();
                role.Name = "Admin";
                roleManager.Create(role);
            }

            var user = new ApplicationUser();

            user.UserName = "******";
            user.Email    = "*****@*****.**";
            string userPWD = "Admin@123";

            var chkUser = UserManager.Create(user, userPWD);

            if (chkUser.Succeeded)
            {
                var result1 = UserManager.AddToRole(user.Id, "Admin");

                NominatingBodyCategory ncat = new NominatingBodyCategory();
                ncat.Name = "Ministries";
                db.NominatingBodyCategories.Add(ncat);
                db.SaveChanges();

                NominatingBody nbody = new NominatingBody();
                nbody.Name  = "ICT Authority";
                nbody.Order = 20;
                nbody.NominatingBodyCategoryId = ncat.Id;
                db.NominatingBodies.Add(nbody);
                db.SaveChanges();

                if (db.PostalCodes.Count() <= 0)
                {
                    ModelService.InsertPostalCodes();
                }

                var userDetails = new UserDetails();
                userDetails.Designation      = "Sofwtare Developer";
                userDetails.EmailAddress     = "*****@*****.**";
                userDetails.MobileNo         = "0724924465";
                userDetails.NominatingBodyId = nbody.Id;
                userDetails.OtherNames       = "Shangala Mwadwaa";
                userDetails.OtherNo          = "0733274699";
                userDetails.PFNumber         = "0099";
                userDetails.PostalAddress    = 5457;
                userDetails.PostalCodeId     = db.PostalCodes.Where(c => c.Code == 100).FirstOrDefault().Id;
                userDetails.Surname          = "Mwadwaa";
                userDetails.Title            = "Mr.";
                userDetails.UserId           = user.Id;
                userDetails.UserStatus       = true;
                db.UserDetails.Add(userDetails);
                db.SaveChanges();
            }

            if (!roleManager.RoleExists("User"))
            {
                var role = new IdentityRole();
                role.Name = "User";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("ApproverStageOne"))
            {
                var role = new IdentityRole();
                role.Name = "ApproverStageOne";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("ApproverStageTwo"))
            {
                var role = new IdentityRole();
                role.Name = "ApproverStageTwo";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("ApproverStageThree"))
            {
                var role = new IdentityRole();
                role.Name = "ApproverStageThree";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("Super Admin"))
            {
                var role = new IdentityRole();
                role.Name = "Super Admin";
                roleManager.Create(role);
            }
        }