Ejemplo n.º 1
0
        public CrudResult <Book> GetExistingBook(string id)
        {
            var exitingBook = GetFromCache(id);

            if (exitingBook != null)
            {
                return(CrudResult <Book> .Success(exitingBook));
            }
            else
            {
                return(CrudResult <Book> .NotFound());
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
        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());
            }
        }
Ejemplo n.º 5
0
        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());
            }
        }