public IHttpActionResult Get(int id)
        {
            #region Preconditions

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

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

            #endregion

            try
            {
                var workingSet = workingSetRepository.GetItem(id);

                var dtoTaskWorkingSet = WorkingSetMapper.TranslateModelWorkingSetToDTOWorkingSet(workingSet);

                return(Ok(dtoTaskWorkingSet));
            }
            catch (Exception ex)
            {
                string res = ex.ToString();
                return(InternalServerError());
            }
        }
Esempio n. 2
0
        public static DTO.Task TranslateModelUserTaskToDTOTask(Model.UserTask ut)
        {
            if (ut == null)
            {
                return(null);
            }

            return(new DTO.Task
            {
                Code = ut.Code,
                Comments = Mapper.TranslateModelCommentListToDTOCommentList(ut.Comments),
                Completed = ut.Completed,
                Control = ControlMapper.TranslateModelControlToDTOControl(ut.Control),
                ControlId = ut.ControlId,
                ControlCode = ut.ControlCode,
                ControlSetCode = ut.ControlSetCode,
                ControlSetId = ut.ControlSetId,
                ControlSetTitle = ut.ControlSetTitle,
                ControlTitle = ut.ControlTitle,
                Created = ut.Created,
                CreatedByUserId = ut.CreatedByUserId,
                Description = ut.Description,
                Due = ut.Due,
                DueStatus = Mapper.TranslateModelDueStatusToDTODueStatus(ut.DueStatus),
                Events = Mapper.TranslateModelEventListToDTOEventList(ut.Events),
                Id = ut.Id,
                Link = ut.Link,
                RaciTeam = Mapper.TranslateModelRaciTeamToDTORaciTeam(ut.RaciTeam),
                TaskDefinitionId = ut.TaskDefinitionId,
                TaskState = Mapper.TranslateModelTaskStateToDTOTaskState(ut.TaskState),
                Title = ut.Title,
                WorkingSet = WorkingSetMapper.TranslateModelWorkingSetToDTOWorkingSet(ut.WorkingSet),
                WorkingSetId = ut.WorkingSetId
            });
        }
        public IHttpActionResult Get()
        {
            #region Preconditions

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

            #endregion

            try
            {
                var workingSets = workingSetRepository.GetItems();

                var dtoWorkingSets = workingSets.Select(utf => WorkingSetMapper.TranslateModelWorkingSetToDTOWorkingSet(utf));

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