public async Task <TaskTypeDto> PutTaskType(int id, TaskTypeDto model) { var url = CRMApiUri + "/TaskType/" + id; var result = await PutRequestToApi(url, model); return(result); }
public async Task <TaskTypeDto> PostTaskType(TaskTypeDto model) { var url = CRMApiUri + "/TaskType"; var result = await PostRequestToApi(url, model); return(result); }
public async Task <BaseEntity> SaveAndReturnEntityAsync(TaskTypeDto entityDto) { var entity = _mapper.Map <TaskType>(entityDto); var result = await _repository.SaveAndReturnEntityAsync(entity); return(result); }
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))); }
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))); }
public TaskTypeDto BuildDto(TaskType entity) { var dto = new TaskTypeDto { Id = (byte)entity.Id, Alias = entity.Alias }; return(dto); }
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); }
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); }
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 })); }
public async Task <int> SaveAsync(TaskTypeDto entityDto) { var result = await SaveAndReturnEntityAsync(entityDto); return(result.Id); }