public static void CreateCategoryAuction() { CreateAuctionCategoryVm newCategory = new CreateAuctionCategoryVm() { Name = "NameCategory", Discription = "TestDiscription" }; AuctionManagementService service = new AuctionManagementService(); service.CreateAuctionCategory(newCategory); }
//добавление категории аукциона public int CreateAuctionCategory(CreateAuctionCategoryVm model) { var checkCategory = _aplicationDbContext.AuctionCategories.FirstOrDefault(p => p.Name == model.Name); if (checkCategory != null) { throw new Exception("incorrect model!"); } AuctionCategory category = new AuctionCategory() { Name = model.Name, Description = model.Discription }; _aplicationDbContext.AuctionCategories.Add(category); _aplicationDbContext.SaveChanges(); return(category.Id); }