コード例 #1
0
ファイル: BookRepository.cs プロジェクト: asiermarin/ATP
        public CrudResult <Book> GetExistingBook(string id)
        {
            var exitingBook = GetFromCache(id);

            if (exitingBook != null)
            {
                return(CrudResult <Book> .Success(exitingBook));
            }
            else
            {
                return(CrudResult <Book> .NotFound());
            }
        }
コード例 #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));
            }
        }
コード例 #3
0
ファイル: BookRepository.cs プロジェクト: asiermarin/ATP
        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());
            }
        }
コード例 #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());
            }
        }
コード例 #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());
            }
        }