Exemplo n.º 1
0
        public T AddCategory <T>(T entity) where T : ProductCategoryModel
        {
            var categoryCriteria = new CategoryCriteria()
            {
                Name = entity.Name
            };

            if (AnyCategory(categoryCriteria))
            {
                return(null);
            }

            var newEntity = _mapper.Map <Category>(entity);

            newEntity.CreationDate = DateTime.Now;

            _context.Categories.Add(newEntity);
            _context.SaveChanges();

            return(_mapper.Map <T>(newEntity));
        }
Exemplo n.º 2
0
 private bool AnyCategory(CategoryCriteria categoryCriteria)
 {
     return(_context.Categories.Any(categoryCriteria.Match()));
 }