Exemplo n.º 1
0
        public JsonResult GetHelm()
        {
            try
            {
                using (var data = new Entities())
                {
                    var classes       = data.Classes.Where(x => x.IsDeleted == false).ToList();
                    var mappedClasses = data.ClassMaps.Where(
                        x => x.IsDeleted == false && x.CredentialId == UserInformation.UserInformationCredential.Id)
                                        .ToList()
                                        .Select(
                        x =>
                        new
                    {
                        x,
                        ClassName =
                            (classes.FirstOrDefault(y => y.Id == x.ClassId)?.ClassName ?? "No Class Name")
                    }).ToList();

                    var mappedSubject = data.SubjectMaps
                                        .Where(
                        x => x.IsDeleted == false && x.CredentialId == UserInformation.UserInformationCredential.Id)
                                        .ToList()
                                        .Select(x =>
                                                new
                    {
                        x,
                        SubjectName =
                            (EnumDictionary.GetList <Subjects>()
                             .FirstOrDefault(y => y.ItemId == x.SubjectId)?
                             .ItemName ?? "No Subject Name")
                    }).ToList();


                    return(new JsonResult()
                    {
                        Data =
                            new
                        {
                            Status = true,
                            Message = $"All Done",
                            Data = new { Subjects = mappedSubject, Classes = mappedClasses }
                        },
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                ActivityLogger.Log(ex);
                return(new JsonResult()
                {
                    Data = new { Status = false, Message = ex.Message, Data = string.Empty },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
        private void FrmCentralTagStudent_Shown(object sender, EventArgs e)
        {
            SetReader(DeviceManager.DeviceSpec.Nfc);

            SetCombo(EnumDictionary.GetList <AttendanceReason>(), cmbAttendanceReason);
            SetCombo(DatabaseManager.SchoolCourse.Select(x => new EnumList()
            {
                ItemId   = x.Id,
                ItemName = x.CourseCode
            }).ToList(), cmbCourse);
        }
Exemplo n.º 3
0
        public ActionResult ClassSubjectManagement(int classSubjectId)
        {
            try
            {
                using (var data = new Entities())
                {
                    var subjectMaps = data.SubjectMaps.Where(x => x.CredentialId == UserInformation.UserInformationCredential.Id).ToList();
                    var classMaps   = data.ClassMaps.Where(x => x.CredentialId == UserInformation.UserInformationCredential.Id).ToList();

                    var classSubject =
                        data.ClassSubjects.Where(
                            x =>
                            x.Id == classSubjectId && x.CredentialId == UserInformation.UserInformationCredential.Id)
                        .ToList()
                        .Select(
                            x =>
                            new ClassSubjectManagement()
                    {
                        ClassSubject = x,
                        SubjectId    = subjectMaps.FirstOrDefault(y => y.Id == x.SubjectId)?.SubjectId,
                        ClassId      = classMaps.FirstOrDefault(y => y.Id == x.ClassId)?.ClassId,
                        ClassName    =
                            data.Classes.ToList().FirstOrDefault(
                                z => z.Id == classMaps.FirstOrDefault(y => y.Id == x.ClassId)?.ClassId)?
                            .ClassName ?? "",
                        SubjectName =
                            EnumDictionary.GetList <Subjects>().ToList()
                            .FirstOrDefault(
                                z =>
                                z.ItemId ==
                                subjectMaps.FirstOrDefault(y => y.Id == x.SubjectId)?.SubjectId)
                                                ?
                            .ItemName ?? ""
                    }).FirstOrDefault();

                    return(classSubject == null?View("Index") : View(classSubject));
                }
            }
            catch (Exception ex)
            {
                ActivityLogger.Log(ex);
                return(View("Index"));
            }
        }
Exemplo n.º 4
0
        // GET: ApiResultManagement
        public JsonResult GetHelm()
        {
            try
            {
                using (var data = new Entities())
                {
                    var classes   = data.Classes.Where(x => x.IsDeleted == false).ToList();
                    var subjects  = EnumDictionary.GetList <Subjects>();
                    var classMaps =
                        data.ClassMaps.Where(x => x.CredentialId == UserInformation.UserInformationCredential.Id && x.IsDeleted == false)
                        .ToList();
                    var subjectMaps =
                        data.SubjectMaps.Where(x => x.CredentialId == UserInformation.UserInformationCredential.Id && x.IsDeleted == false)
                        .ToList();

                    return(new JsonResult()
                    {
                        Data =
                            new
                        {
                            Status = true,
                            Message = $"Success",
                            Data =
                                new
                            {
                                Assessments =
                                    data.Assessments.Where(x => x.IsDeleted == false)
                                    .OrderBy(x => x.AssessmentName)
                                    .ToList(),
                                Classes = classMaps
                                          .ToList()
                                          .Select(
                                    x =>
                                    new
                                {
                                    x,
                                    ClassName =
                                        classes.FirstOrDefault(y => y.Id == x.ClassId)?
                                        .ClassName ?? ""
                                }),
                                Subjects = subjectMaps
                                           .ToList()
                                           .Select(
                                    x =>
                                    new
                                {
                                    x,
                                    SubjectName =
                                        subjects.FirstOrDefault(y => y.ItemId == x.SubjectId)?
                                        .ItemName ?? ""
                                })
                            }
                        },
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                ActivityLogger.Log(ex);
                return(new JsonResult()
                {
                    Data = new { Status = false, Message = ex.Message, Data = string.Empty },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
Exemplo n.º 5
0
        public JsonResult GetClassSubjects()
        {
            try
            {
                var credentialId = UserInformation.UserInformationCredential.Id;
                using (var data = new Entities())
                {
                    var activeSession = data.EducationalPeriods.FirstOrDefault(x => x.IsActive && !x.IsDeleted);
                    if (activeSession == null)
                    {
                        return new JsonResult()
                               {
                                   Data =
                                       new
                                   {
                                       Status  = false,
                                       Message =
                                           $"Please check if the Administrator has created an Active Session Active Sub-Session"
                                   },
                                   JsonRequestBehavior = JsonRequestBehavior.AllowGet
                               }
                    }
                    ;

                    var activeSubSession = data.SubEducationalPeriods.FirstOrDefault(x => x.IsActive && !x.IsDeleted && x.EducationalPeriodId == activeSession.Id);
                    if (activeSubSession == null)
                    {
                        return new JsonResult()
                               {
                                   Data =
                                       new
                                   {
                                       Status  = false,
                                       Message = $"Please check if the Administrator has created an Active Sub-Session"
                                   },
                                   JsonRequestBehavior = JsonRequestBehavior.AllowGet
                               }
                    }
                    ;

                    var listOfSubjects = EnumDictionary.GetList <Subjects>();
                    var listOfClasses  = data.Classes.Where(x => x.IsDeleted == false).ToList();
                    var subjectMaps    = data.SubjectMaps.Where(x => x.CredentialId == credentialId).ToList();
                    var classMaps      = data.ClassMaps.Where(x => x.CredentialId == credentialId).ToList();

                    var classSubjectRaw =
                        data.ClassSubjects.Where(
                            x =>
                            !x.IsDeleted && x.SessionId == activeSession.Id && x.SubSessionId == activeSubSession.Id &&
                            x.CredentialId == credentialId)
                        .AsEnumerable()
                        .Select(
                            x =>
                            new
                    {
                        x,
                        subjectMaps.FirstOrDefault(y => y.Id == x.SubjectId)?.SubjectId,
                        classMaps.FirstOrDefault(y => y.Id == x.ClassId)?.ClassId
                    })
                        .ToList();

                    var classSubjects = classSubjectRaw
                                        .Select(c => new
                    {
                        c.x,
                        NameOfClassSubject =
                            $"{listOfClasses.FirstOrDefault(x => x.Id == c.ClassId)?.ClassName} {listOfSubjects.FirstOrDefault(x => x.ItemId == c.SubjectId)?.ItemName}",
                        MemberResultNumber = data.ClassSubjectMemberResults.Count(x => x.ClassSubjectId == c.x.Id)
                    }).ToList();

                    return(new JsonResult()
                    {
                        Data = new { Status = true, Message = $"Successful", Data = classSubjects },
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                ActivityLogger.Log(ex);
                return(new JsonResult()
                {
                    Data = new { Status = false, Message = ex.Message, Data = string.Empty },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
Exemplo n.º 6
0
        public JsonResult GetUser(string username)
        {
            try
            {
                using (var data = new Entities())
                {
                    var allClasses  = data.Classes.Where(x => x.IsDeleted == false).ToList();
                    var allSubjects = EnumDictionary.GetList <Subjects>();

                    var userInformation =
                        data.Credentials.FirstOrDefault(x => x.IsDeleted == false && x.Username == username);

                    var mappedClassesRaw =
                        data.ClassMaps
                        .Where(x => x.IsDeleted == false && x.CredentialId == userInformation.Id).ToList();

                    var mappedSubjectsRaw =
                        data.SubjectMaps.Where(x => x.IsDeleted == false && x.CredentialId == userInformation.Id)
                        .ToList();

                    var mappedClasses =
                        allClasses.Select(
                            c =>
                            new
                    {
                        c,
                        MappingStatus = (mappedClassesRaw.FirstOrDefault(m => m.ClassId == c.Id) != null)
                    })
                        .OrderBy(x => x.c.ClassName)
                        .ToList();

                    var mappedSubjects =
                        allSubjects.Select(
                            s => new
                    {
                        s,
                        MappingStatus = (mappedSubjectsRaw.FirstOrDefault(m => m.SubjectId == s.ItemId) != null)
                    })
                        .OrderBy(x => x.s.ItemName)
                        .ToList();

                    return(new JsonResult()
                    {
                        Data =
                            new
                        {
                            Status = true,
                            Message = $"Found User",
                            Data =
                                new
                            {
                                UserInformation = userInformation,
                                MappedClasses = mappedClasses,
                                MappedSubject = mappedSubjects,
                                TotalClasses = mappedClasses.Count,
                                TotalSubjects = mappedSubjects.Count
                            }
                        },
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                ActivityLogger.Log(ex);
                return(new JsonResult()
                {
                    Data = new { Status = false, Message = ex.Message, Data = string.Empty },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }