示例#1
0
        public IActionResult GetAll()
        {
            var result = new ObjectResult(_repo.GetAll())
            {
                StatusCode = (int)HttpStatusCode.OK
            };

            // add total counts to header
            Request.HttpContext.Response.Headers.Add("X-Total-Count", _repo.GetAll().Count().ToString());
            return(result);
        }
示例#2
0
        public Task <GenericQueryResult> Handle(GetFormsRequest request, CancellationToken cancellationToken)
        {
            try
            {
                var forms = _formRepository.GetAll();

                if (forms == null)
                {
                    return(Task.FromResult(new GenericQueryResult(404, "Não existe nenhum form cadastrado!", null)));
                }

                var result = forms.Select(
                    f =>
                    new GetFormsResponse()
                {
                    FormId          = f.Id,
                    FormTitle       = f.Title,
                    AuthorName      = _authorRepository.Get(f.AuthorId).Name,
                    QuestionsNumber = _questionRepository.Get(f.Id).Count,
                    CreatedAt       = f.CreatedAt.ToString("dd/MM/yyyy"),
                    Answered        = f.Answered
                }
                    );

                return(Task.FromResult(new GenericQueryResult(200, null, result.OrderBy(f => f.FormTitle))));
            }
            catch
            {
                return(Task.FromResult(new GenericQueryResult(500, "Erro no servidor! Desculpe-nos.", null)));
            }
        }
示例#3
0
        public List <FormModel> Get()
        {
            var formModels = new List <FormModel>();
            var forms      = formRepository.GetAll();

            foreach (var form in forms)
            {
                formModels.Add(Get(form.Id));
            }
            return(formModels);
        }
        public async Task <List <Form> > GetAll(User user)
        {
            var forms = await FormRepository.GetAll();

            foreach (var form in forms)
            {
                form.Status = await getStatus(user.Username, form.Id);

                form.MaxPoints = form.Questions.Where(q => q.IsCorrected).Count() * 1.0;
            }

            foreach (var form in forms.Where(f => f.Status == FormStatus.Answered))
            {
                var response = await getSelectedAnswers(user, forms, form);

                form.Points = calculatePoints(form, response.Answers);
            }

            return(forms);
        }
 public async Task <List <Form> > GetAll()
 {
     return(await FormRepository.GetAll());
 }
 public async Task <IEnumerable <FormVM> > GetForms()
 {
     return(await _formRepository.GetAll());
 }
示例#7
0
 public IEnumerable <Form> GetAllForm(string lang = "", string active = "")
 {
     return(databasePlaceholder.GetAll(lang, active));
 }
示例#8
0
 public ResultMessage <ICollection <Form> > GetAll(Expression <Func <Form, bool> > filter = null)
 {
     return(_formRepository.GetAll(filter));
 }
示例#9
0
        public IEnumerable <Form> GetForms()
        {
            var forms = formRepository.GetAll("FormField");

            return(forms);
        }
 public ActionResult List()
 {
     return(View(_formRepository.GetAll().OrderByDescending(x => x.FormId)));
 }
示例#11
0
        public IEnumerable <Form> GetForms()
        {
            var forms = formRepository.GetAll(); // içerde FormField yazıyordu

            return(forms);
        }