Skip to content

Instantly share code, notes, and snippets.

@bklooste
Last active July 19, 2017 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bklooste/72ac65860dd20cc4a96d3348b027f68b to your computer and use it in GitHub Desktop.
Save bklooste/72ac65860dd20cc4a96d3348b027f68b to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
using Cosmos.Common.Contracts;
using System;
// fixme
namespace Cosmos.Services
{
public interface ICrudGetService<T> : ICosmosService where T : IHasId, IIsModifyable
{
// get
Task<long> Count(); //200
Task<T> Get(Guid id , bool includeDeleted = false); //200 , 404
Task<Guid[]> GetAllIds(); //200 , 404
Task<T[]> GetAll(bool includeDeleted = false); //200 , 404
Task<T[]> GetAll(Guid[] ids); //200 , 404
Task<NameValue[]> GetAllNames(); //200 , 404
Task Delete(Guid id); //200 , 404
}
public interface ICrudPostService<T> : ICosmosService where T : IHasId//, IIsModifyable
{
////post we skip the mosts
Task AddOrUpdate(T record); // 204 , 400
Task AddOrUpdateMany(T[] records); // 204 , 400
}
// we may need more than T[] but that could be a different method.
public interface IVersionedService<T> : ICosmosService where T : IHasVer
{
Task<T[]> GetByVer(long position , int maxCount); //200 , 404
}
// while simpler to use this contract will expose some extra fields that are ignored
public interface ICrudService<T> : ICrudGetService<T> , ICrudPostService<T> where T : IHasId , IIsModifyable
{
}
}
@bklooste
Copy link
Author

Aaron Wyatt suggest getting a list of names as objects could be deep HDS. I have added returning NameValue..

@bklooste
Copy link
Author

Should arrays be replaced with IEnumerable ? I think so... the reason for arrays is serialisation behaviour but most serializers are pretty good these days in terms of mapping collections to arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment