/// <summary> /// This is the read implementation. /// </summary> /// <param name="key">The key.</param> /// <param name="holder">The request holder.</param> /// <returns></returns> protected override async Task <IResponseHolder <E> > InternalRead(K key, PersistenceRequestHolder <K, E> holder) { E entity; bool success = Container.TryGetValue(key, out entity); if (success) { JsonHolder <K> jsonHolder = mTransform.JsonMaker(entity); return(new PersistenceResponseHolder <E>(PersistenceResponse.Ok200, jsonHolder.Json, mTransform.PersistenceEntitySerializer.Deserializer(jsonHolder.Json))); } else { return(new PersistenceResponseHolder <E>(PersistenceResponse.NotFound404)); } }
/// <summary> /// The internal version by reference command. /// </summary> /// <param name="reference">The reference.</param> /// <param name="holder">The request holder.</param> /// <returns></returns> protected override async Task <IResponseHolder> InternalVersionByRef(Tuple <string, string> reference, PersistenceRequestHolder <K, Tuple <K, string> > holder) { E entity; bool success = Container.TryGetValue(reference, out entity); if (success) { JsonHolder <K> jsonHolder = mTransform.JsonMaker(entity); return(new PersistenceResponseHolder(PersistenceResponse.Ok200, jsonHolder.Json)); } else { return(new PersistenceResponseHolder(PersistenceResponse.NotFound404)); } }
/// <summary> /// This is the create override for the command. /// </summary> /// <param name="key">The key.</param> /// <param name="holder">The entity holder.</param> /// <returns>Returns the response encapsulated in a PersistenceResponseHolder object.</returns> protected override async Task <IResponseHolder <E> > InternalCreate(K key, PersistenceRequestHolder <K, E> holder) { E entity = holder.Rq.Entity; int response = EntityPopulate(key, entity); if (response == 201) { JsonHolder <K> jsonHolder = mTransform.JsonMaker(entity); return(new PersistenceResponseHolder <E>(PersistenceResponse.Created201, jsonHolder.Json, mTransform.PersistenceEntitySerializer.Deserializer(jsonHolder.Json))); } else { return(new PersistenceResponseHolder <E>(PersistenceResponse.Conflict409)); } }