Esempio n. 1
0
        public ActionResult Index()
        {
            var currentAcademicYear = Convert.ToInt32(_academicYearRepository.GetCurrentAcademicYear().Year.ToString(CultureInfo.InvariantCulture));
            var loggedUserEmail     = _securityRepository.GetUserLoggedEmail();

            _loggedParent = _parentRepository.Filter(y => y.MyUser.Email == loggedUserEmail).FirstOrDefault();
            var userId = _securityRepository.GetUserLogged().Id;
            var personalNotifications = _notificationRepository.GetPersonalNotifications(currentAcademicYear, userId).ToList();
            var notifications         = _notificationRepository.GetGradeNotifications(currentAcademicYear, userId).ToList();

            notifications.AddRange(_notificationRepository.GetAreaNotifications(currentAcademicYear, userId).ToList());
            notifications.AddRange(_notificationRepository.GetGeneralNotifications(currentAcademicYear).ToList());
            var personalNotificationsModel = new List <NotificationModel>();
            var notificationsModel         = new List <NotificationModel>();

            foreach (var notification in personalNotifications)
            {
                var noti = Mapper.Map <NotificationModel>(notification);
                noti.CommentsAmount      = notification.NotificationComments.Count;
                noti.NotificationCreator = notification.UserCreatorName;
                // if(noti.Id != )
                personalNotificationsModel.Add(noti);
            }
            foreach (var notification in notifications)
            {
                var noti = Mapper.Map <Notification, NotificationModel>(notification);
                noti.CommentsAmount      = notification.NotificationComments.Count;
                noti.NotificationCreator = notification.UserCreatorName;
                notificationsModel.Add(noti);
            }
            personalNotificationsModel = personalNotificationsModel.OrderByDescending(x => x.Created).ToList();
            notificationsModel         = notificationsModel.OrderByDescending(x => x.Created).ToList();
            return(View(new Tuple <List <NotificationModel>, List <NotificationModel> >(personalNotificationsModel, notificationsModel)));
        }
Esempio n. 2
0
        public ActionResult LogIn(ParentLoginModel model, string returnUrl)
        {
            var parent = model.Email.Contains("@") ? _parentRepository.Filter(y => y.MyUser.Email == model.Email).FirstOrDefault()
                : _parentRepository.Filter(y => y.IdNumber == model.Email).FirstOrDefault();

            if (parent != null)
            {
                if (_sessionManagementRepository.LogIn(model.Email, model.Password))
                {
                    if (parent.MyUser.Email.Equals(""))
                    {
                        return(RedirectToAction("ConfirmEmail"));
                    }

                    return(RedirectToAction("Index", "Notification"));
                }

                ModelState.AddModelError("", "El nombre de usuario o la contraseña especificados son incorrectos.");
                return(View(model));
            }
            ModelState.AddModelError("", "El usuario ingresado no es un padre");
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            _viewMessageLogic.SetViewMessageIfExist();
            var allParents = _parentRepository.GetAllParents();

            ViewBag.CurrentSort      = sortOrder;
            ViewBag.NameSortParm     = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.IdNumberSortParm = sortOrder == "IdNumber" ? "idNumber_desc" : "IdNumber";
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            if (!string.IsNullOrEmpty(searchString))
            {
                allParents = _parentRepository.Filter(x => x.FullName.Contains(searchString)).ToList();
            }
            var allParentDisplaysModel = allParents.Select(Mapper.Map <Parent, DisplayParentModel>).ToList();

            ViewBag.CurrentFilter = searchString;
            switch (sortOrder)
            {
            case "name_desc":
                allParentDisplaysModel = allParentDisplaysModel.OrderByDescending(s => s.FullName).ToList();
                break;

            case "IdNumber":
                allParentDisplaysModel = allParentDisplaysModel.OrderBy(s => s.IdNumber).ToList();
                break;

            case "idNumber_desc":
                allParentDisplaysModel = allParentDisplaysModel.OrderByDescending(s => s.IdNumber).ToList();
                break;

            default:      // Name ascending
                allParentDisplaysModel = allParentDisplaysModel.OrderBy(s => s.FullName).ToList();
                break;
            }
            const int pageSize   = 10;
            var       pageNumber = (page ?? 1);

            return(View(allParentDisplaysModel.ToPagedList(pageNumber, pageSize)));
        }
Esempio n. 4
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            var parent = _parentRepository.Filter(y => y.MyUser.Email == model.UserEmail).FirstOrDefault();

            if (parent == null)
            {
                if (_sessionManagement.LogIn(model.UserEmail, model.Password, model.RememberMe))
                {
                    return(RedirectToLocal(returnUrl));
                }
            }
            else
            {
                ModelState.AddModelError("", "El usurio no tiene privilegios para entrar a esta pagina");
                return(View(model));
            }
            // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
            ModelState.AddModelError("", "El nombre de usuario o la contraseña especificados son incorrectos.");
            return(View(model));
        }