Esempio n. 1
0
        public bool LookupCategory(int id, out CategoryReadModel category)
        {
            var foundCategory = _repository.LookupCategory(id);

            if (foundCategory == null)
            {
                category = null;
                return(false);
            }

            category = _mapper.Map <CategoryReadModel>(foundCategory);
            return(true);
        }
Esempio n. 2
0
        public bool Delete(int id, out CategoryReadModel deletedCategory)
        {
            var foundCategory = _repository.LookupCategory(id);

            if (foundCategory == null)
            {
                deletedCategory = null;
                return(false);
            }

            _repository.Delete(foundCategory);
            _repository.SaveChanges();

            deletedCategory = _mapper.Map <CategoryReadModel>(foundCategory);
            return(true);
        }
Esempio n. 3
0
        public bool Add(Input.CategoryCreateModel category, out CategoryReadModel createdCategory)
        {
            var commandDatabaseModel = _mapper.Map <Database.CategoryModel>(category);

            try
            {
                _repository.Create(commandDatabaseModel);
                _repository.SaveChanges();
            }
            catch (Exception exception)
            {
                //TODO: Beef this up for real production environment
                _logger.LogError("Something went Boom", exception);
                createdCategory = null;
                return(false);
            }

            createdCategory = _mapper.Map <CategoryReadModel>(commandDatabaseModel);
            return(true);
        }