/// <summary> /// Updates the protocol. /// </summary> /// <param name="customerId"></param> /// <param name="protocolId">The protocol identifier.</param> /// <param name="request">The request.</param> /// <returns></returns> public async Task <CreateUpdateProtocolStatus> UpdateProtocol( int customerId, Guid protocolId, UpdateProtocolRequestDto request ) { #region Step 1 - Client IDs validation var validationResult = PerformValidationStep1(request); if (!validationResult.HasFlag(CreateUpdateProtocolStatus.Success)) { return(validationResult); } #endregion #region Step 2 - Remaining Validation which can be made only after successfuly passed step 1 validationResult = await PerformValidationStep2(request); if (!validationResult.HasFlag(CreateUpdateProtocolStatus.Success)) { return(validationResult); } #endregion var updatedProtocol = await BuildProtocol(customerId, request); var result = await protocolService.UpdateProtocol(customerId, protocolId, updatedProtocol); updatedProtocol.Id = protocolId; await globalSearchCacheHelper.AddOrUpdateEntry(customerId, Mapper.Map <Protocol, SearchEntryDto>(updatedProtocol)); await tagsSearchCacheHelper.AddOrUpdateTags(customerId, updatedProtocol.Tags.Select(t => t.Name).ToList()); var unusedTags = await tagsService.RemoveUnusedTags(customerId); await tagsSearchCacheHelper.RemoveTags(customerId, unusedTags); return(result); }
public async Task <IHttpActionResult> UpdateProtocol( int customerId, Guid protocolId, UpdateProtocolRequestDto request ) { var status = await protocolsControllerHelper.UpdateProtocol(customerId, protocolId, request); if (status.HasFlag(CreateUpdateProtocolStatus.ProtocolWithSuchIdDoesNotExist)) { return(Content( HttpStatusCode.NotFound, new ErrorResponseDto() { Error = ErrorCode.InvalidRequest, Message = ErrorCode.InvalidRequest.Description(), Details = status.GetConcatString() } )); } if (!status.HasFlag(CreateUpdateProtocolStatus.Success)) { return(Content( HttpStatusCode.BadRequest, new ErrorResponseDto() { Error = ErrorCode.InvalidRequest, Message = ErrorCode.InvalidRequest.Description(), Details = status.GetConcatString() } )); } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Updates the protocol. /// </summary> /// <param name="protocol">The protocol.</param> /// <returns></returns> public Task UpdateProtocol(UpdateProtocolRequestDto protocol) { var token = authDataStorage.GetToken(); return(healthLibraryService.UpdateProtocol(token, CustomerContext.Current.Customer.Id, protocol)); }
/// <summary> /// Updates the protocol. /// </summary> /// <param name="token">The token.</param> /// <param name="customerId">The customer identifier.</param> /// <param name="protocol">The protocol.</param> /// <returns></returns> public Task UpdateProtocol(string token, int customerId, UpdateProtocolRequestDto protocol) { return(healthLibraryDataProvider.UpdateProtocol(token, customerId, protocol)); }
public async Task <ActionResult> UpdateProtocol(UpdateProtocolRequestDto request) { await careBuilderManager.UpdateProtocol(request); return(Json(string.Empty)); }
/// <summary> /// Updates the protocol. /// </summary> /// <param name="token">The token.</param> /// <param name="customerId">The customer identifier.</param> /// <param name="protocol">The protocol.</param> /// <returns></returns> public Task UpdateProtocol(string token, int customerId, UpdateProtocolRequestDto protocol) { var url = string.Format("/api/{0}/protocols/{1}", customerId, protocol.Id); return(apiClient.SendRequestAsync(url, protocol, Method.PUT, null, token)); }