コード例 #1
0
        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
        //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"));
        }
コード例 #5
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"));
 }
コード例 #6
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"));
        }