public void Execute(CategoryDto request) { validator.ValidateAndThrow(request); var category = mapper.Map <Category>(request); context.Category.Add(category); context.SaveChanges(); }
public void Execute(CategoriesDto request) { _validator.ValidateAndThrow(request); var category = new Categories { Name = request.Name, }; _context.Categories.Add(category); _context.SaveChanges(); }
public void Execute(CategoryDto request, int id) { _validator.ValidateAndThrow(request); var categories = _context.Categories.Find(id); if (categories == null) { } categories.Name = request.Name; categories.ModifiedAt = DateTime.Now; _context.SaveChanges(); }
public void Execute(CategoryDto request) { _validator.ValidateAndThrow(request); var category = new Category { Name = request.Name, CreatedAt = DateTime.Now, IsActive = true }; _context.Categories.Add(category); _context.SaveChanges(); }
public void Execute(CategoriesDto request, int id) { _validator.ValidateAndThrow(request); var category = _context.Categories.Find(id); if (category == null) { throw new NotFoundEntityException(id, typeof(Categories)); } category.Name = request.Name; _context.SaveChanges(); }
public void Execute(CategoryDto request) { validator.ValidateAndThrow(request); var category = context.Categories.Find(request.Id); if (category == null) { throw new EntityNotFoundException(request.Id, typeof(Category)); } var categoryy = context.Categories.Where(x => x.Id == request.Id).First(); mapper.Map(request, categoryy); context.SaveChanges(); }
public void Execute(CategoryDto request, int id) { var category = _context.Categories.Find(id); if (category == null) { throw new EntityNotFoundException(id, typeof(Category)); } _validator.ValidateAndThrow(request); category.Name = request.Name; category.ModifiedAt = DateTime.Now; _context.SaveChanges(); }