예제 #1
0
        /// <summary>
        /// Retourne la note correspondant à l'identifiant
        /// </summary>
        /// <param name="id">Identifiant de la note</param>
        /// <returns>Entité <see cref="Note"/></returns>
        public Note GetNoteById(int id)
        {
            NoteQuery query  = new NoteQuery(monContexte);
            Note      result = query.GetById(id);

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Retourne les notes correspondant à un élève
        /// </summary>
        /// <param name="eleveId">Identifiant de l'élève</param>
        /// <returns>Liste d'entités <see cref="Note"/></returns>
        public List <Note> GetNotesByEleveId(int eleveId)
        {
            NoteQuery   query  = new NoteQuery(monContexte);
            List <Note> result = query.GetByEleveId(eleveId);

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Retourne toutes les notes
        /// </summary>
        /// <returns>Liste d'entités <see cref="Note"/></returns>
        public List <Note> GetAllNotes()
        {
            NoteQuery   query  = new NoteQuery(monContexte);
            List <Note> result = query.GetAll();

            return(result);
        }
예제 #4
0
        public async Task <List <NoteModel> > Get(NoteQuery filter)
        {
            if (!filter.IdObserver.HasValue)
            {
                filter.IdObserver = this.GetIdObserver();
            }

            return(await _mediator.Send(filter));
        }
예제 #5
0
        /// <summary>
        /// Permet d'obtenir la moyenne de l'élève
        /// </summary>
        /// <param name="eleveId">Identifiant de l'élève</param>
        /// <returns></returns>
        public double GetAverageByEleveId(int eleveId)
        {
            NoteQuery   query  = new NoteQuery(monContexte);
            List <Note> result = query.GetByEleveId(eleveId);

            if (result.Count() == 0)
            {
                return(0);
            }

            return(result.Average(n => n.ValeurNote));
        }
예제 #6
0
        /// <summary>
        /// Récupérer la moyenne des notes en base par l'ID de l'élève
        /// </summary>
        /// <param name="eleveID">Identifiant de l'élève</param>
        /// <returns>string</returns>
        public string GetAvgByEleveId(int eleveID)
        {
            NoteQuery   nq    = new NoteQuery(contexte);
            List <Note> notes = nq.GetByEleveID(eleveID).ToList();

            if (notes.Count == 0)
            {
                return("Aucunes notes.");
            }
            double moy = notes.Average(note => note.Valeur);

            return(moy.ToString());
        }
예제 #7
0
        public async Task <List <NoteModel> > Get(NoteQuery filter)
        {
            if (!this.IsTokenValid(_tokenService.GetTemporaryToken(this.GetCurrentUserId())))
            {
                throw new UnauthorizedAccessException();
            }

            if (!filter.UserId.HasValue || filter.UserId <= 0)
            {
                filter.UserId = this.GetCurrentUserId();
            }

            return(await _mediator.Send(filter));
        }
예제 #8
0
 public async Task <List <NoteModel> > Handle(NoteQuery message, CancellationToken token)
 {
     return(await _context.Notes
            .Where(n => n.IdObserver == message.IdObserver && n.IdPollingStation == message.IdPollingStation)
            .OrderBy(n => n.LastModified)
            .Select(n => new NoteModel
     {
         AttachmentPath = n.AttachementPath,
         Text = n.Text,
         FormCode = n.Question.FormSection.Form.Code,
         FormId = n.Question.FormSection.Form.Id,
         QuestionId = n.Question.Id
     })
            .ToListAsync(cancellationToken: token));
 }
예제 #9
0
        public Eleve GetOneEleve(int id)
        {
            EleveQuery eq = new EleveQuery(context);

            Eleve e = eq.GetOne(id);

            NoteQuery nq = new NoteQuery(context);

            e.Notes = nq.GetByEleveId(id).ToList();
            AbsenceQuery aq = new AbsenceQuery(context);

            e.Absences = aq.GetByEleveId(id).ToList();

            return(e);
        }
예제 #10
0
        public List <Eleve> GetAllEleve()
        {
            EleveQuery eq = new EleveQuery(context);

            List <Eleve> eleves = new List <Eleve>();

            foreach (Eleve e in eq.GetAll().ToList())
            {
                NoteQuery nq = new NoteQuery(context);
                e.Notes = nq.GetByEleveId(e.Id).ToList();
                AbsenceQuery aq = new AbsenceQuery(context);
                e.Absences = aq.GetByEleveId(e.Id).ToList();
                eleves.Add(e);
            }
            return(eleves);
        }
예제 #11
0
        public async Task <NoteCollection> List(NoteQuery query)
        {
            var dbQuery = await query.Create(this.Entities);

            var total = await dbQuery.CountAsync();

            if (total == 0)
            {
                await this.Add(new NoteInput()
                {
                    Text = "First Note\n\nThis is the first note."
                });

                total = await dbQuery.CountAsync();
            }
            dbQuery = dbQuery.Skip(query.SkipTo(total)).Take(query.Limit);
            var results = await mapper.MapNote(dbQuery).ToListAsync();

            return(new NoteCollection(query, total, results));
        }
        public async Task <List <NoteModel> > Handle(NoteQuery message, CancellationToken token)
        {
            // check if beneficiary exists and that the current user is allowed to view the beneficiary notes
            var currentUser = await _context.Users.FirstOrDefaultAsync(u => u.UserId == message.UserId);

            var beneficiary = _context.Beneficiaries.Include(b => b.User).FirstOrDefault(b => b.BeneficiaryId == message.BeneficiaryId);

            if (beneficiary == null || (currentUser.NgoId != beneficiary.User.NgoId))
            {
                throw new UnauthorizedAccessException();
            }

            if (message.FormId > 0)
            {
                return(await _context.Notes
                       .Where(n => n.UserId == message.UserId && n.BeneficiaryId == message.BeneficiaryId && n.Question.FormSection.Form.FormId == message.FormId)
                       .OrderBy(n => n.LastModified)
                       .Select(n => new NoteModel
                {
                    AttachmentPath = n.AttachementPath,
                    Text = n.Text,
                    QuestionId = n.QuestionId,
                    LastModified = n.LastModified
                })
                       .ToListAsync(cancellationToken: token));
            }
            else
            {
                return(await _context.Notes
                       .Where(n => n.UserId == message.UserId && n.BeneficiaryId == message.BeneficiaryId && n.QuestionId == null)
                       .OrderBy(n => n.LastModified)
                       .Select(n => new NoteModel
                {
                    AttachmentPath = n.AttachementPath,
                    Text = n.Text,
                    LastModified = n.LastModified
                })
                       .ToListAsync(cancellationToken: token));
            }
        }
예제 #13
0
        public List <Note> GetNotesByEleve(int EleveID)
        {
            NoteQuery query = new NoteQuery(_contexte);

            return(query.GetNotesByEleve(EleveID));
        }
예제 #14
0
        public Note DeleteNote(int noteId)
        {
            NoteQuery query = new NoteQuery(_contexte);

            return(query.DeleteNote(noteId));
        }
예제 #15
0
        public int AddNote(Note n)
        {
            NoteQuery query = new NoteQuery(_contexte);

            return(query.AddNote(n));
        }
예제 #16
0
        /// <summary>
        /// Récupérer les notes en base par l'ID de l'élève
        /// </summary>
        /// <returns>List<Notes></Notes></returns>
        public List <Note> GetNotesByEleveId(int eleveID)
        {
            NoteQuery nq = new NoteQuery(contexte);

            return(nq.GetByEleveID(eleveID).ToList());
        }
예제 #17
0
        /// <summary>
        /// Récupérer une note en base par son ID
        /// </summary>
        /// <returns>Note</returns>
        public Note GetNoteById(int noteID)
        {
            NoteQuery nq = new NoteQuery(contexte);

            return(nq.GetByID(noteID).SingleOrDefault());
        }
예제 #18
0
        /// <summary>
        /// Récupérer une liste de note en base
        /// </summary>
        /// <returns>Liste de Note</returns>
        public List <Note> GetAllNote()
        {
            NoteQuery nq = new NoteQuery(contexte);

            return(nq.GetAll().ToList());
        }
예제 #19
0
        public List <Note> GetNotesByEleve(int idEleve)
        {
            NoteQuery nq = new NoteQuery(contexte);

            return(nq.GetNotesByEleve(idEleve).ToList());
        }
예제 #20
0
        public List <Note> GetNotesByEleve(int eleveId)
        {
            NoteQuery query = new NoteQuery(_monContexte);

            return(query.GetAll().ToList());
        }
예제 #21
0
 public async Task <NoteCollection> List([FromQuery] NoteQuery query)
 {
     return(await repo.List(query));
 }
예제 #22
0
        public Note GetNoteById(int idNote)
        {
            NoteQuery nq = new NoteQuery(contexte);

            return(nq.GetNoteById(idNote));
        }