public ActionResult Edit(long id)
        {
            EducationLevel thisArea = _areaReposity.GetById(id);
            var            area     = Mapper.Map <EducationLevel, EducationLevelEditModel>(thisArea);

            return(View("Edit", area));
        }
Пример #2
0
        public ActionResult Add(CourseRegisterModel modelCourse)
        {
            string title;
            string content;
            var    courseModel = Mapper.Map <CourseRegisterModel, Course>(modelCourse);

            courseModel.Area = _areaRepository.GetById(modelCourse.Area);
            var myCourse    = _courseRepository.GenerateCourseFromRegisterModel(courseModel);
            var existCourse =
                _courseRepository.GetAllCourse()
                .FirstOrDefault(c => c.Name.Equals(modelCourse.Name));

            if (existCourse != null)
            {
                title   = "Materia";
                content = "La materia " + existCourse.Name + " ya existe.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.InformationMessage);
                return(RedirectToAction("Index"));
            }
            var newCourse = _courseRepository.Create(myCourse);

            title   = "Materia Agregada";
            content = "La materia " + newCourse.Name + " ha sido agregada exitosamente.";
            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public bool DeleteEducationLevel(int id)
        {
            bool isSuccess      = true;
            var  educationLevel = educationLevelRepository.GetById(id);

            try
            {
                educationLevelRepository.Delete(educationLevel);
                SaveRecord();
                ServiceUtil <EducationLevel> .WriteActionLog(id, ENUMOperation.DELETE);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in deleting EducationLevel", ex);
            }
            return(isSuccess);
        }
Пример #4
0
        public async Task <ActionResult <EducationLevel> > Edit(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                var EducationLevel = await _EducationLevel.GetById(id);

                return(View(EducationLevel));
            }
            else
            {
                return(BadRequest());
            }
        }
        private string GetDestinationName(Notification notification)
        {
            switch (notification.NotificationType)
            {
            case NotificationType.General:
                return("General");

            case NotificationType.EducationLevel:
                var educationLevel = _educationLevelRepository.GetById(notification.DestinationId);
                return("Nivel de educacion: " + educationLevel.Name);

            case NotificationType.Grade:
                var grade = _gradeRepository.GetById(notification.DestinationId);
                return("Grado: " + grade.Name);

            case NotificationType.Section:
                var singleGrade =
                    _academicGradeRepository.Filter(x => x.Id == notification.DestinationId &&
                                                    x.AcademicYear.Id == notification.AcademicYear.Id).FirstOrDefault();
                if (singleGrade != null)
                {
                    return(singleGrade.Grade.Name + " Grado Seccion " + singleGrade.Section);
                }
                return("");

            case NotificationType.Course:
                var course = _academicCourseRepository.Filter(x => x.Id == notification.DestinationId &&
                                                              x.AcademicGrade.AcademicYear.Id ==
                                                              notification.AcademicYear.Id).FirstOrDefault();
                if (course != null)
                {
                    return(course.AcademicGrade.Grade.Name + " " + course.AcademicGrade.Section + " (" +
                           course.Course.Name + ")");
                }
                return("");

            case NotificationType.Student:
                var singleStudent = _studentRepository.Filter(x => x.Id == notification.DestinationId).FirstOrDefault();
                if (singleStudent != null)
                {
                    return(singleStudent.FirstName);
                }
                return("");

            default:
                return("");
            }
        }
Пример #6
0
        private void AddUsersToLevelNotification(Notification notificationIdentity)
        {
            var area   = _areaReporsitory.GetById(notificationIdentity.IdGradeAreaUserGeneralSelected);
            var grades = _gradeRepository.GetAllGrade().Where(x => x.EducationLevel.Equals(area.Name)).Select(x => x.Id).ToList();

            if (!grades.Any())
            {
                return;
            }
            foreach (var id in grades)
            {
                long id1         = id;
                var  studentList = _enrollRepository.GetAllsEnrolls().Where(x => x.AcademicYear.Grade.Id == id1 &&
                                                                            x.AcademicYear.Year == DateTime.Now.Year)
                                   .Select(x => x.Student).ToList();
                if (!studentList.Any())
                {
                    continue;
                }
                foreach (var student in studentList)
                {
                    var student1             = student;
                    var notificationParentId = _studentRepository.Query(x => x).Where(x => x.Id == student1.Id &&
                                                                                      x.Tutor1 != null)
                                               .Select(x => x.Tutor1).Include(x => x.MyUser)
                                               .FirstOrDefault();
                    if (notificationParentId != null)
                    {
                        if (notificationParentId.MyUser != null)
                        {
                            notificationIdentity.Users.Add(notificationParentId.MyUser);
                        }
                    }
                    notificationParentId = _studentRepository.GetAllStudents().Where(x => x.Id == student.Id &&
                                                                                     x.Tutor2 != null && x.Tutor2 != x.Tutor1)
                                           .Select(x => x.Tutor2).FirstOrDefault();
                    if (notificationParentId != null)
                    {
                        User parents = _userRepository.GetById(notificationParentId.MyUser.Id);
                        if (parents != null)
                        {
                            notificationIdentity.Users.Add(parents);
                        }
                    }
                }
            }
        }
Пример #7
0
        private void DebuggingSeeder(MhotivoContext context)
        {
            var passwordsList = new List <string>
            {
                "arbol",
                "madera",
                "republica",
                "imperio",
                "crucio",
                "excursion",
                "pitonisa",
                "ventilador",
                "oraculo",
                "sanguineo"
            };

            _passwordGenerationService.AddPasswordsToTable(passwordsList);
            _areaRepository.Create(new EducationLevel {
                Name = "Prescolar"
            });
            _areaRepository.Create(new EducationLevel {
                Name = "Primaria"
            });
            _areaRepository.Create(new EducationLevel {
                Name = "Secundaria"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(1).Name, Name = "Kinder"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(1).Name, Name = "Preparatoria"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Primero"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Segundo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Tercero"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Cuarto"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Quinto"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Sexto"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Septimo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Octavo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Noveno"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Decimo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Onceavo"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(1), Name = "English"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(1), Name = "Math"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "English"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Math"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Science"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Espaniol"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Estudios Sociales"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Algebra"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Geometry"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Physics"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Biology"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Physical Education"
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(1), Grade = _gradeRepository.GetById(1)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(1), Grade = _gradeRepository.GetById(2)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(2), Grade = _gradeRepository.GetById(2)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(2), Grade = _gradeRepository.GetById(1)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(3), Grade = _gradeRepository.GetById(3)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(3), Grade = _gradeRepository.GetById(4)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(4), Grade = _gradeRepository.GetById(5)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(5), Grade = _gradeRepository.GetById(6)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(6), Grade = _gradeRepository.GetById(7)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(7), Grade = _gradeRepository.GetById(8)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(8), Grade = _gradeRepository.GetById(9)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(12), Grade = _gradeRepository.GetById(10)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(9), Grade = _gradeRepository.GetById(11)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(10), Grade = _gradeRepository.GetById(12)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(11), Grade = _gradeRepository.GetById(13)
            });
            for (int i = 1; i <= 13; i++)
            {
                _academicYearRepository.Create(new AcademicYear {
                    Approved = true, Grade = _gradeRepository.GetById(i), IsActive = true, Section = "A", Year = 2015
                });
                _academicYearRepository.Create(new AcademicYear {
                    Approved = true, Grade = _gradeRepository.GetById(i), IsActive = true, Section = "B", Year = 2015
                });
                _academicYearRepository.Create(new AcademicYear {
                    Approved = true, Grade = _gradeRepository.GetById(i), IsActive = true, Section = "C", Year = 2015
                });
            }
            var genericTeacher = new User
            {
                DisplayName = "Maestro Generico",
                Email       = "*****@*****.**",
                Password    = "******",
                IsActive    = true,
                Role        = Roles.Maestro
            };

            genericTeacher.EncryptPassword();
            var genericParent = new User
            {
                DisplayName = "Padre Generico",
                Email       = "*****@*****.**",
                Password    = "******",
                IsActive    = true,
                Role        = Roles.Padre
            };

            genericParent.EncryptPassword();
            context.Users.AddOrUpdate(genericTeacher);
            context.Users.AddOrUpdate(genericParent);
            context.SaveChanges();
            var maestroDefault = context.Teachers.FirstOrDefault(x => x.FullName == "Maestro Generico");

            if (maestroDefault == null)
            {
                context.Teachers.AddOrUpdate(new Teacher {
                    IdNumber = "0000000000000", FirstName = "Maestro", LastName = "Generico", FullName = "Maestro Generico", Disable = false, MyGender = Gender.Masculino, MyUser = genericTeacher
                });
            }
            var padreDefault = context.Parents.FirstOrDefault(x => x.FullName == "Padre Generico");

            if (padreDefault == null)
            {
                context.Parents.AddOrUpdate(new Parent {
                    IdNumber = "1234567890", FirstName = "Padre", LastName = "Generico", FullName = "Padre Generico", Disable = false, MyGender = Gender.Femenino, MyUser = genericParent
                });
            }
            context.SaveChanges();
        }
Пример #8
0
        public async Task <ActionResult <Advertisiment> > Create(Advertisiment value, IFormCollection Col)
        {
            List <EthinicalGroup> eths = new List <EthinicalGroup>();
            List <AdvAndEth>      adv  = new List <AdvAndEth> ();
            List <string>         exam = new List <string>();

            int i = 0;
            int j = 0;

            foreach (string key in Col.Keys)
            {
                AdvAndEth adve = new AdvAndEth();

                int values = 0;
                if (key.Contains("EthinicalGroup") && !key.Contains("value"))
                {
                    EthinicalGroup eth = await _ethinicalGroup.GetById(Col[key]);

                    values = Convert.ToInt32(Col[key + "value"]);

                    eths.Add(eth);
                    adve.GetEthinicalGroup = eth;
                    adve.Value             = values;
                    adv.Add(adve);
                }

                //if (key == "EthinicalGroup[" + i + "]")
                //{
                //    EthinicalGroup eth = await _ethinicalGroup.GetById(Col["EthinicalGroup[" + i + "]"]);
                //    values = Convert.ToInt32(Col["EthinicalGroup[" + i + "]value"]);

                //    eths.Add(eth);
                //    adve.GetEthinicalGroup = eth;
                //    adve.Value = values;
                //    adv.Add(adve);
                //    i++;


                //}
                if (key.Contains("Exam"))
                {
                    string examtype = Col[key];
                    exam.Add(examtype);
                    j++;
                }
            }
            value.Examtype        = exam;
            value.EthinicalGroups = eths;
            value.AdvAndEths      = adv;
            value.Group           = await _Group.GetById(value.GroupId.ToString());

            value.SubGroup = await _SubGroup.GetById(value.SubGroupId.ToString());

            value.Service = await _service.GetById(value.ServiceId.ToString());

            value.Category = await _category.GetById(value.CategoryId.ToString());

            value.Post = await _post.GetById(value.PostId.ToString());

            value.Edu = await _educationLavel.GetById(value.EducationId.ToString());

            _Advertisiment.Add(value);

            // it will be null
            //var testAdvertisiment = await _Advertisiment.GetById(value.);

            // If everything is ok then:
            await _uow.Commit();

            // The product will be added only after commit
            // testProduct = await _productRepository.GetById(product.Id);

            return(RedirectToAction("Index"));
        }
Пример #9
0
 public EducationLevelDto Get(short id)
 {
     return(_educationLevelRepository.GetById(id).Mapper());
 }