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

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

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

            #endregion

            try
            {
                var control = controlRepository.GetItem(id);

                var dtoControl = ControlMapper.TranslateModelControlToDTOControl(control);

                return(Ok(dtoControl));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
예제 #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
            });
        }
예제 #3
0
        public IHttpActionResult Get()
        {
            #region Preconditions

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

            #endregion

            try
            {
                var controls = controlRepository.GetItems();

                var dtoControls = controls.Select(cs => ControlMapper.TranslateModelControlToDTOControl(cs));

                return(Ok(dtoControls));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }