public CrudResult <Book> GetExistingBook(string id) { var exitingBook = GetFromCache(id); if (exitingBook != null) { return(CrudResult <Book> .Success(exitingBook)); } else { return(CrudResult <Book> .NotFound()); } }
public CrudResult <IDictionary <string, Car> > GetAllExistingCar() { var dictionaryCars = GetFromCache(DictionaryCarsKey); if (dictionaryCars == null) { return(CrudResult <IDictionary <string, Car> > .NotFound()); } else { return(CrudResult <IDictionary <string, Car> > .Success(dictionaryCars)); } }
public CrudResult RemoveExistingBook(string id) { var result = GetExistingBook(id); if (result.IsSuccess) { return(RemoveBook(result.Value)); } else if (result.IsNotFound) { return(CrudResult.NotFound()); } else { return(CrudResult.Error()); } }
public CrudResult RemoveExistingCar(string reference) { var dictionaryCars = GetAllExistingCar(); if (dictionaryCars.IsSuccess) { var succesfull = dictionaryCars.Value.Remove(reference); if (succesfull) { return(UpdateCacheData(dictionaryCars.Value)); } else { return(CrudResult.Error()); } } else { return(CrudResult.NotFound()); } }
public CrudResult <Car> GetExistingCar(string reference) { var dictionaryCars = GetAllExistingCar(); if (dictionaryCars.IsSuccess) { var car = dictionaryCars.Value .Where(x => x.Key == reference) .SingleOrDefault(); if (car.Value == null) { return(CrudResult <Car> .NotFound()); } else { return(CrudResult <Car> .Success(car.Value)); } } else { return(CrudResult <Car> .NotFound()); } }