public ActionResult Edit(Department model)
        {
            if (ModelState.IsValid && _service.Update(model))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error");
            return(View(model));
        }
        public ActionResult DeletePost(int id)
        {
            if (ModelState.IsValid && _umsFacade.DeleteDepartment(id))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Index"));
            }

            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error");
            return(View(_service.GetById(id)));
        }
        public ActionResult Delete(Registration model)
        {
            model = _service.GetById(model.Id);
            if (ModelState.IsValid && _service.Delete(model.Id))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.SectionId }));
            }

            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error");
            return(View(model));
        }
        public ActionResult Create(Section model)
        {
            if (ModelState.IsValid && _service.Insert(model))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            ViewBag.Courses      = _courseService.GetAll();
            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error");
            return(View(model));
        }
Beispiel #5
0
        public ActionResult EditPost(Student model)
        {
            ModelState["Password"].Errors.Clear();

            if (ModelState.IsValid && _service.Update(model))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            ViewBag.Departments  = _departmentService.GetAll();
            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error");
            return(View(model));
        }
Beispiel #6
0
        public ActionResult Create(User model)
        {
            using (MD5 md5Hash = MD5.Create())
            {
                model.Password = _cryptoHelper.GetMd5Hash(md5Hash, "0");
            }
            ModelState["Password"].Errors.Clear();

            if (ModelState.IsValid && _service.Insert(model))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error. Note: Username and Email must be unique");
            return(View(model));
        }
Beispiel #7
0
        public ActionResult EditPost(User model)
        {
            ModelState["Password"].Errors.Clear();

            if (ModelState.IsValid && _service.Update(model))
            {
                User user = Session["User"] as User;
                if (user.Id == model.Id)
                {
                    return(RedirectToAction("Login", "Account"));
                }

                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error. Note: Username and Email must be unique");
            return(View(model));
        }
        public ActionResult Create(Registration model)
        {
            Student student = _studentService.GetByFormattedId(Request["formattedId"]);
            Section section = _sectionService.GetById(model.SectionId);

            if (student != null && section != null)
            {
                model.DateTime  = System.DateTime.Now;
                model.StudentId = student.Id;
                if (ModelState.IsValid && student.DepartmentId == section.Course.DepartmentId && _service.Insert(model))
                {
                    TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                    return(RedirectToAction("Details", new { id = model.SectionId }));
                }
            }

            model.Section        = section;
            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "The Student is already Registered in this section or does not belong to this course");
            return(View(model));
        }
        public ActionResult ChangePassword(ChangePasswordVM model)
        {
            User user = _mapper.Map <ChangePasswordVM, User>(model);

            if (ModelState.IsValid && _authService.ValidateUser(user))
            {
                using (MD5 md5Hash = MD5.Create())
                {
                    user.Password = _cryptoHelper.GetMd5Hash(md5Hash, model.NewPassword);

                    if (_userService.UpdatePassword(user))
                    {
                        TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success", "Your last action was successful.");
                        return(RedirectToAction("Logout"));
                    }
                }
            }

            TempData["AlertMessage"] = AlertHelper.DangerAlert("Unsuccessful", "You might have provided wrong data.");

            return(View(model));
        }
        public ActionResult ResetPassword(String email)
        {
            if (String.IsNullOrEmpty(email))
            {
                ViewBag.AlertMessage = AlertHelper.DangerAlert("Missing", "Please enter your email");
            }
            else if (_userService.GetByEmail(email) == null)
            {
                ViewBag.AlertMessage = AlertHelper.DangerAlert("Invalid Email", "Account does not exist");
            }
            else
            {
                MailMessage mail = new MailMessage();
                //TODO: create mail with password reset link
                if (_emailService.SendEmail(mail))
                {
                    ViewBag.AlertMessage = AlertHelper.SuccessAlert("Success!", "Password reset link has been sent to your email");
                }
            }

            return(View(model: email));
        }
Beispiel #11
0
        public ActionResult Create(Student model)
        {
            model.Type = UserType.Student;
            using (MD5 md5Hash = MD5.Create())
            {
                model.Password = _cryptoHelper.GetMd5Hash(md5Hash, "0");
            }
            ModelState["Password"].Errors.Clear();
            int count = ((ICollection)_service.GetAll()).Count;

            model.FormattedId = String.Format($"{DateTime.Now.Year.ToString().Substring(2, 2)}-{model.DepartmentId}-{count}");
            ModelState["FormattedId"].Errors.Clear();

            if (ModelState.IsValid && _service.Insert(model))
            {
                TempData["AlertMessage"] = AlertHelper.SuccessAlert("Success!", "Your last operation was successful");
                return(RedirectToAction("Details", new { id = model.Id }));
            }

            ViewBag.Departments  = _departmentService.GetAll();
            ViewBag.AlertMessage = AlertHelper.DangerAlert("Error!", "Your last operation issued an error");
            return(View(model));
        }