public ViewResult Respons(DateTime date, string startTijdUur, string startTijdMinuten, string eindTijdUur, string eindTijdMinuten, string reden)
        {
            var context           = new PlanningSysteemEntities();
            var newUnavailability = new Unavailability();

            newUnavailability.UnavailabilityCause     = reden;
            newUnavailability.UnavailabilityStartTime = new DateTime(date.Year, date.Month, date.Day, Convert.ToInt16(startTijdUur), Convert.ToInt16(startTijdMinuten), 0);
            newUnavailability.UnavailabilityEndTime   = new DateTime(date.Year, date.Month, date.Day, Convert.ToInt16(eindTijdUur), Convert.ToInt16(eindTijdMinuten), 0);
            newUnavailability.userID = 3;
            context.Unavailability.Add(newUnavailability);
            var addedUnavailability = new Models.Unavailability
            {
                UnavailabilityStartTime = newUnavailability.UnavailabilityStartTime,
                UnavailabilityEndTime   = newUnavailability.UnavailabilityEndTime,
                UnavailabilityCause     = newUnavailability.UnavailabilityCause
            };

            try
            {
                context.SaveChanges();
                addedUnavailability.UnavailabilityCause = "Uploaden gelukt";
                return(View(addedUnavailability));
            }
            catch (System.Data.Entity.Core.EntityException)
            {
                context.Unavailability.Remove(newUnavailability);
                addedUnavailability.UnavailabilityCause = "Uploaden gefaald";

                return(View(addedUnavailability));
            }
        }
Пример #2
0
        public ActionResult EditCourse(int?id)
        {
            var context = new PlanningSysteemEntities();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var courseToUpdate = context.Course.Find(id);

            if (TryUpdateModel(courseToUpdate, "", new string[] { "courseCode", "courseName", "description" }))
            {
                try
                {
                    context.SaveChanges();
                    return(RedirectToAction("Overview", "Course"));
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }

            return(View(courseToUpdate));
        }
Пример #3
0
        // POST: Account/Reset
        public ActionResult ResetAccount(Account currentAccount)
        {
            string newPassword; // = "testrggr";

            var context = new PlanningSysteemEntities();

            if (context.Account.Any(a => a.username == currentAccount.username))
            {
                const string Chars  = "ABCDEFGHIJKLMNPOQRSTUVWXYZ0123456789";
                var          random = new System.Random();
                var          result = new string(
                    Enumerable.Repeat(Chars, 8)
                    .Select(s => s[random.Next(s.Length)])
                    .ToArray());
                newPassword = result;

                using (context)
                {
                    Account accountCurrent = context.Account.Where(a => a.username == currentAccount.username).FirstOrDefault();
                    accountCurrent.password   = result;
                    accountCurrent.isResetted = true;
                    context.SaveChanges();
                }
            }
            else
            {
                newPassword = "******";
                //return RedirectToAction("Reset", "Account");
            }

            return(RedirectToAction("resettedpassword", "Account", new { password = newPassword }));
        }
Пример #4
0
        // GET: Account
        public ActionResult Overview()
        {
            PlanningSysteemEntities context     = new PlanningSysteemEntities();
            List <Models.Account>   allAccounts = new List <Models.Account>();
            List <Account>          accounts    = context.Account.Where(a => a.isDisabled == false).ToList();

            foreach (Account i in accounts)
            {
                Models.Role roleinDB = new Models.Role()
                {
                    roleId   = i.Role.roleId,
                    roleName = i.Role.roleName
                };
                Models.Account account = new Models.Account()
                {
                    userId     = i.userId,
                    username   = i.username,
                    role       = roleinDB,
                    createdAt  = i.createdAt,
                    firstLogin = i.firstLogin
                };
                allAccounts.Add(account);
            }
            return(View(allAccounts));
        }
Пример #5
0
        public ActionResult Edit(int?id)
        {
            var context = new PlanningSysteemEntities();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Course course = context.Course.Find(id);

            if (course == null)
            {
                return(HttpNotFound());
            }
            return(View());
        }
Пример #6
0
        //POST: Course

        public ActionResult DisableCourse(int courseId)
        {
            var context = new PlanningSysteemEntities();

            try
            {
                Course course = context.Course.Find(courseId);
                context.Course.Remove(course);
                context.SaveChanges();
            }
            catch (DataException)
            {
                return(RedirectToAction("Disable", "Course"));
            }

            return(RedirectToAction("Disable", "Course"));
        }
Пример #7
0
 public ActionResult Create([Bind(Include = "courseId,courseCode,courseName,description")] Course course)
 {
     try
     {
         var context = new PlanningSysteemEntities();
         if (ModelState.IsValid)
         {
             context.Course.Add(course);
             context.SaveChanges();
             return(RedirectToAction("Overview", "Course"));
         }
     }
     catch (RetryLimitExceededException /* dex */)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
     }
     return(RedirectToAction("Overview", "Course"));
 }
Пример #8
0
        public ActionResult Create()
        {
            var context = new PlanningSysteemEntities();

            List <Role>           roles = context.Role.ToList();
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (var role in roles)
            {
                items.Add(new SelectListItem
                {
                    Text  = role.roleName,
                    Value = role.roleId.ToString()
                });
            }
            ViewData["ListItems"] = items;
            return(View());
        }
Пример #9
0
        // POST: Account/Create
        public ActionResult CreateAccount(Models.Account account)
        {
            var context    = new PlanningSysteemEntities();
            var newAccount = new Account
            {
                userId     = account.userId,
                username   = account.username,
                password   = account.password,
                roleId     = Int32.Parse(Request.Form["Role"]),
                firstLogin = account.firstLogin = true,
                isResetted = account.isResetted = false,
                createdAt  = account.createdAt = DateTime.Now,
                isDisabled = account.isDisabled = false
            };

            context.Account.Add(newAccount);
            context.SaveChanges();
            return(RedirectToAction("Overview", "Account"));
        }
Пример #10
0
        // GET: Course
        public ActionResult Overview()
        {
            var context = new PlanningSysteemEntities();
            List <Models.Course> allCourses = new List <Models.Course>();
            var courses = context.Course.ToList();

            foreach (Course i in courses)
            {
                Models.Course course = new Models.Course()
                {
                    courseId    = i.courseId,
                    courseCode  = i.courseCode,
                    courseName  = i.courseName,
                    description = i.description,
                };
                allCourses.Add(course);
            }

            return(View(allCourses));
        }
        public ActionResult Login(Account account)
        {
            PlanningSysteemEntities context = new PlanningSysteemEntities();
            bool status = false;


            if (context.Account.Any(a => a.username == account.username && a.password == account.password))
            {
                status = true;
                Session["Username"] = account.username;

                TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
                string UserUniqueKey       = account.username + key;
                Session["UserUniqueKey"] = UserUniqueKey;
                SetupCode setupInfo = tfa.GenerateSetupCode("PlanningSysteem", account.username, UserUniqueKey, 300, 300);
                ViewBag.BarcodeImageUrl = setupInfo.QrCodeSetupImageUrl;
                ViewBag.SetupCode       = setupInfo.ManualEntryKey;
            }

            ViewBag.Status = status;
            return(View());
        }