Beispiel #1
0
        public IHttpActionResult Get(int id)
        {
            #region Preconditions

            if (userTaskRepository == null)
            {
                throw new InvalidOperationException();
            }

            if (id <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            #endregion

            try
            {
                logger.Info($"TasksController Get id: {id} ", users.First(u => u.UserName == User.Identity.Name).Id);

                var userTask = userTaskRepository.GetItem(id);

                var dtoTask = UserTaskMapper.TranslateModelUserTaskToDTOTask(userTask);

                return(Ok(dtoTask));
            }
            catch (Exception ex)
            {
                logger.Error($"TasksController Get id: {id}, Error:  {ex.Message}", users.First(u => u.UserName == User.Identity.Name).Id);
                return(InternalServerError());
            }
        }
Beispiel #2
0
        public IHttpActionResult Get(int id)
        {
            #region Preconditions

            if (userTaskRepository == null)
            {
                throw new InvalidOperationException();
            }

            if (id <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            #endregion

            try
            {
                var userTask = userTaskRepository.GetItem(id);

                var dtoTask = UserTaskMapper.TranslateModelUserTaskToDTOTask(userTask);

                return(Ok(dtoTask));
            }
            catch (Exception ex)
            {
                return(InternalServerError());
            }
        }