Beispiel #1
0
        public async Task <IHttpActionResult> GetData(string Param)
        {
            try
            {
                var     sid = RequestContext.Principal.Identity.Name;
                webData WD  = new webData();
                WD.user    = CPR.SNSE.AspNetUsers.Where(u => u.UserName == sid).AsNoTracking().First();
                WD.student = CPR.SNSE.Students.Where(s => s.SecID == WD.user.Id)
                             .Include(s => s.StudentTeams)
                             .Include(s => s.StudentOffers)
                             .Include(s => s.StudentRequests)
                             .Include(s => s.Contact)
                             .AsNoTracking().FirstOrDefault();

                WD.subjects = await  GetStudentMatches(WD.student.ID);

                WD.categories = CPR.SNSE.SubjectCategories.OrderBy(s => s.CategoryName).AsNoTracking().ToList();
                int?teamID = WD.student.StudentTeams.Select(s => s.TeamID).FirstOrDefault();
                if (teamID != null)
                {
                    Team ATeam = CPR.SNSE.Teams.Where(t => t.ID == teamID).Include(t => t.School).AsNoTracking().First();
                    WD.school = ATeam.School;
                }
                WD.teams = CPR.SNSE.Teams.Where(t => t.SchoolID == WD.school.ID).AsNoTracking().ToList();

                return(Ok(WD));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.InternalServerError, e.Message));

                ;
            }
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetMatches(string Param)
        {
            try
            {
                var     sid = RequestContext.Principal.Identity.Name;
                webData WD  = new webData();
                WD.user = await CPR.SNSE.AspNetUsers.Where(u => u.UserName == sid).AsNoTracking().FirstAsync();

                Student student = CPR.SNSE.Students.Where(s => s.SecID == WD.user.Id)
                                  .AsNoTracking()
                                  .FirstOrDefault();

                return(Ok(GetStudentMatches(student.ID)));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.InternalServerError, e.Message));

                ;
            }
        }