Exemplo n.º 1
0
        public JsonResult SearchEvaluationTarget(SectionSearchViewModel evaluationViewModel)
        {
            var token = _tokenValidator.Validate(HttpContext);

            if (!token.Success)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    NotAuthenticated = true,
                    Message = $"Unauthorized:-{token.Message}",
                }));
            }

            var result   = _unisolApiProxy.ReturnEvaluationTargetSearch(evaluationViewModel).Result;
            var response = new ProcessJsonReturnResults <List <SectionSearch> >(result).UnisolApiData;

            return(Json(response));
        }
Exemplo n.º 2
0
        public JsonResult ReturnEvaluationTargetSearch([FromBody] SectionSearchViewModel searchObject)
        {
            var sectionSearch = new List <SectionSearch>();

            if (searchObject.TargetType == TargetDepartmentLevel.Faculty)
            {
                var faculties = _context.Schools.Where(s => !(bool)s.Closed && s.Names.ToUpper().Contains(searchObject.SearchString.ToUpper())).Take(15);
                if (faculties.Any())
                {
                    faculties.ToList().ForEach(d =>
                    {
                        sectionSearch.Add(new SectionSearch
                        {
                            Id     = d.Id,
                            Names  = d.Names,
                            Extras = d.Notes
                        });
                    });
                }
            }

            if (searchObject.TargetType == TargetDepartmentLevel.Department)
            {
                var depts = _context.Department.Where(d => (bool)d.Tuition && !(bool)d.Closed && d.Names.ToUpper().Contains(searchObject.SearchString.ToUpper())).Take(15);
                if (depts.Any())
                {
                    depts.ToList().ForEach(d =>
                    {
                        sectionSearch.Add(new SectionSearch
                        {
                            Id     = d.Id,
                            Names  = d.Names,
                            Extras = d.School
                        });
                    });
                }
            }
            if (searchObject.TargetType == TargetDepartmentLevel.Program)
            {
                var programs = _context.Programme.Where(d => !(bool)d.Closed && d.Names.ToUpper().Contains(searchObject.SearchString.ToUpper())).Take(15);
                if (programs.Any())
                {
                    programs.ToList().ForEach(d =>
                    {
                        sectionSearch.Add(new SectionSearch
                        {
                            Id     = d.Id,
                            Names  = d.Names,
                            Extras = d.Notes
                        });
                    });
                }
            }

            if (searchObject.TargetType == TargetDepartmentLevel.Class)
            {
                var academicClass = _context.Class
                                    .Where(d => d.Starts > DateTime.UtcNow && d.Ends < DateTime.UtcNow && d.Id.ToUpper()
                                           .Contains(searchObject.SearchString.ToUpper())).Take(15);
                if (academicClass.Any())
                {
                    academicClass.ToList().ForEach(d =>
                    {
                        sectionSearch.Add(new SectionSearch
                        {
                            Id     = 0,
                            Names  = d.Id,
                            Extras = d.Notes
                        });
                    });
                }
            }

            if (searchObject.TargetType == TargetDepartmentLevel.Student)
            {
                var academicClass = _context.Register.Where(d => !(bool)d.Closed && d.Names.ToUpper().Contains(searchObject.SearchString.ToUpper())).Take(15);
                if (academicClass.Any())
                {
                    academicClass.ToList().ForEach(d =>
                    {
                        sectionSearch.Add(new SectionSearch
                        {
                            Id     = d.Id,
                            Names  = d.Names,
                            Extras = d.Email
                        });
                    });
                }
            }

            var message = sectionSearch.Count > 0 ? "Details Have been found" : "No search records found";

            return(Json(new ReturnData <List <SectionSearch> >
            {
                Success = sectionSearch.Count > 0,
                Data = sectionSearch,
                Message = message
            }));
        }
Exemplo n.º 3
0
        public Task <string> ReturnEvaluationTargetSearch(SectionSearchViewModel searchObject)
        {
            var response = Post("department/ReturnEvaluationTargetSearch/", searchObject);

            return(response);
        }