Beispiel #1
0
        public async Task <ActionResult <IEnumerable <TaskAggregate> > > GetMyTasks()
        {
            if (!Request.Headers.TryGetValue(Constants.UserIdHeaderName, out StringValues userIdValue))
            {
                return(BadRequest($"Header {Constants.UserIdHeaderName} must be specified"));
            }

            string userId = userIdValue.ToString();

            try
            {
                var result = await _tasksManager.GetUserTasksAsync(userId);

                var list = result.list;
                if (result.fromCache)
                {
                    Response.StatusCode = (int)_cacheFoundCode;
                    return(new ActionResult <IEnumerable <TaskAggregate> >(list));
                }
                return(Ok(list));
            }
            catch (Exception e)
            {
                return(BadRequest($"{e.GetType().Name}: {e.Message}\n{e.StackTrace}"));
            }
        }
        public async Task <ActionResult <IEnumerable <TaskAggregate> > > GetMyTasks()
        {
            if (!Request.Headers.TryGetValue(Constants.UserIdHeaderName, out StringValues userIdValue))
            {
                return(BadRequest($"Header {Constants.UserIdHeaderName} must be specified"));
            }

            string userId = userIdValue.ToString();

            try
            {
                return(Ok(await _tasksManager.GetUserTasksAsync(userId)));
            }
            catch (Exception e)
            {
                return(BadRequest($"{e.GetType().Name}: {e.Message}\n{e.StackTrace}"));
            }
        }