public async Task <Tr> CreateTr(int CategoryId, Tr Tr) { Tr.CategoryId = CategoryId; await ValidateCategory(CategoryId); var TrEntity = mapper.Map <TrEntity>(Tr); EcomakRepository.CreateTr(TrEntity); if (await EcomakRepository.SaveChangesAsync()) { return(mapper.Map <Tr>(TrEntity)); } throw new Exception("there where and error with the DB"); }