Beispiel #1
0
        public ActionResult Create([Bind(Include = "id,itemName,itemEndDate,itemStartDate,itemOrder,itemStatus,programmeId,createdBy,createDate")] CommiteeItem commiteeItem)
        {
            if (ModelState.IsValid)
            {
                commiteeItem.createDate = System.DateTime.UtcNow.AddHours(2);
                commiteeItem.createdBy  = User.Identity.Name;
                commiteeItem.itemStatus = Commitee.Models.CommiteeItem.ItemStatus.NOT_STARTED;
                commiteeItem.itemOrder  = db.CommiteeItems.OrderByDescending(w => w.itemOrder).FirstOrDefault().itemOrder + 1;
                db.CommiteeItems.Add(commiteeItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.programmeId = db.CommiteePrograms.Where(w => w.programmeStatus == CommiteeProgramme.CommiteeProgrammeStatus.ACTIVE).ToList();
            return(View(commiteeItem));
        }
Beispiel #2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            CreditCommiteeDB db = new CreditCommiteeDB();
            // Rol tanımlama adımları
            RoleStore <ApplicationRole>   roleStore   = new RoleStore <ApplicationRole>(db);
            RoleManager <ApplicationRole> roleManager = new RoleManager <ApplicationRole>(roleStore);

            if (!roleManager.RoleExists("Admin"))
            {
                ApplicationRole adminRole = new ApplicationRole("Admin");
                roleManager.Create(adminRole);
            }
            if (!roleManager.RoleExists("User"))
            {
                ApplicationRole userRole = new ApplicationRole("User");
                roleManager.Create(userRole);
            }

            UserStore <ApplicationUser>   userStore   = new UserStore <ApplicationUser>(db);
            UserManager <ApplicationUser> userManager = new UserManager <ApplicationUser>(userStore);

            if (userManager.FindByEmail("*****@*****.**") == null)
            {
                ApplicationUser userNormal = new ApplicationUser()
                {
                    Email = "*****@*****.**", UserName = "******"
                };
                userManager.Create(userNormal, "user1234");

                userNormal = userManager.FindByEmail("*****@*****.**");
                //add roles
                userManager.AddToRole(userNormal.Id, "User");
            }


            if (userManager.FindByEmail("*****@*****.**") == null)
            {
                ApplicationUser userAdmin = new ApplicationUser();
                userAdmin = new ApplicationUser()
                {
                    Email = "*****@*****.**", UserName = "******"
                };
                userManager.Create(userAdmin, "admin1234");

                userAdmin = userManager.FindByEmail("*****@*****.**");
                //add roles
                userManager.AddToRole(userAdmin.Id, "Admin");
            }
            db.SaveChanges();
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "id,programmeName,programmeDate")] CommiteeProgramme commiteeProgram)
        {
            List <CommiteeProgramme> activeProgrammes = db.CommiteePrograms.Where(w => w.programmeStatus == CommiteeProgramme.CommiteeProgrammeStatus.ACTIVE).ToList();

            if (activeProgrammes.Count > 0)
            {
                ModelState.AddModelError("", "There is already an ACTIVE programme. To create new one, please complete the previous one.");
            }
            else
            {
                if (ModelState.IsValid)
                {
                    commiteeProgram.programmeStatus = CommiteeProgramme.CommiteeProgrammeStatus.ACTIVE;
                    commiteeProgram.createDate      = System.DateTime.UtcNow.AddHours(2);
                    commiteeProgram.createdBy       = User.Identity.Name;
                    db.CommiteePrograms.Add(commiteeProgram);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(commiteeProgram));
        }