Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ExceptionConverter : IExceptionConverter
- {
- //need the parameter
- public HttpStatusCode Convert(/*need to pass this the repository method*/)
- {
- try
- {
- //call the void repository method here
- }
- catch (Exception exception)
- {
- if (exception is ObjectNotFoundException)
- return HttpStatusCode.NotFound;
- if (exception is InvalidOperationException)
- return HttpStatusCode.BadRequest;
- }
- return HttpStatusCode.OK;
- }
- }
- public interface IHandleCrudOperations
- {
- //All of these methods need to be able to take in many different parameters
- //They will always need a parameter though
- void Remove();
- void Add();
- void Edit();
- void Clone();
- }
- //userRepository
- public void Remove(int userKey)
- public void Add(User user)
- public void Edit(User user)
- public void Clone(CloneUserRequest)
- //groupRepository
- public void Remove(string groupName)
- public void Add(string groupName)
- public void Edit(EditGroupRequest)
- public void Clone(CloneGroupRequest)
- public interface IHandleCrudOperations
- {
- //All of these methods need to be able to take in many different parameters
- //They will always need a parameter though
- void Remove<T>(T item);
- void Add<T>(T item);
- void Edit<T>(T item);
- void Clone<T>(T item);
- }
- //userRepository
- public void Remove<T>(T item)
- {
- //SERIOUS code smell here
- var userKey = (int)(object)item
- //stuff
- }
- //groupRepository
- public void Remove<T>(T item)
- {
- //SERIOUS code smell here
- var groupName = (string)(object)item
- //stuff
- }
- public interface IHandleCrudOperations<TRemove, TAdd, TEdit, TClone>
- {
- void Remove(TKey item);
- void Add(TAdd item);
- void Edit(TEdit item);
- void Clone(TClone item);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement