示例#1
0
        public async Task <TaskTypeDto> PutTaskType(int id, TaskTypeDto model)
        {
            var url    = CRMApiUri + "/TaskType/" + id;
            var result = await PutRequestToApi(url, model);

            return(result);
        }
示例#2
0
        public async Task <TaskTypeDto> PostTaskType(TaskTypeDto model)
        {
            var url    = CRMApiUri + "/TaskType";
            var result = await PostRequestToApi(url, model);

            return(result);
        }
示例#3
0
        public async Task <BaseEntity> SaveAndReturnEntityAsync(TaskTypeDto entityDto)
        {
            var entity = _mapper.Map <TaskType>(entityDto);
            var result = await _repository.SaveAndReturnEntityAsync(entity);

            return(result);
        }
示例#4
0
        public async Task <IActionResult> Put(int id, [FromBody] TaskTypeDto taskType)
        {
            if (id == 0 || taskType.Id == 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _taskTypeService.SaveAndReturnEntityAsync(taskType)));
        }
示例#5
0
        public async Task <IActionResult> Post([FromBody] TaskTypeDto taskType)
        {
            if (taskType.Id != 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _taskTypeService.SaveAndReturnEntityAsync(taskType)));
        }
示例#6
0
        public TaskTypeDto BuildDto(TaskType entity)
        {
            var dto = new TaskTypeDto
            {
                Id    = (byte)entity.Id,
                Alias = entity.Alias
            };

            return(dto);
        }
示例#7
0
        public TaskType BuildEntity(TaskTypeDto dto)
        {
            var entity = new TaskType(dto.Alias)
            {
                Id = dto.Id
            };

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            entity.ResetDirtyProperties(false);
            return(entity);
        }
示例#8
0
        public static TaskTypeDto Map(TaskType entity)
        {
            var dto = new TaskTypeDto();

            dto.Id          = entity.Id;
            dto.Description = entity.Description;
            dto.ServiceLevelAgreementMinutes = entity.ServiceLevelAgreementMinutes;
            dto.WarningWindowMinutes         = entity.WarningWindowMinutes;
            dto.CreatedOn      = entity.CreatedOn;
            dto.LastModifiedOn = entity.LastModifiedOn;
            dto.Deleted        = entity.Deleted;
            //todo: don't do LastModifiedBy in here, have a 'MapWithLastModifiedBy' method - otherwise infinately recursive call.
            //todo: don't do CreatedBy in here, have a 'MapWithCreatedBy' method - otherwise infinately recursive call.
            return(dto);
        }
示例#9
0
        public IActionResult Save(TaskTypeDto model)
        {
            UpdateAuditInformation(model);
            if (!ModelState.IsValid)
            {
                GetStateSettings(ViewState.Write);
                return(PartialView("Edit", model));
            }
            model = model.Id > 0
                ? _lookupFacadeApiClient.PutTaskType(model.Id, model).Result
                : _lookupFacadeApiClient.PostTaskType(model).Result;

            if (!string.IsNullOrWhiteSpace(model.ErrorMessage))
            {
                return(PartialView("Edit", model));
            }
            return(Json(new { message = model.SuccessMessage }));
        }
示例#10
0
        public async Task <int> SaveAsync(TaskTypeDto entityDto)
        {
            var result = await SaveAndReturnEntityAsync(entityDto);

            return(result.Id);
        }