コード例 #1
0
ファイル: Program.cs プロジェクト: MeushRoman/AuctionExam
        public static void CreateCategoryAuction()
        {
            CreateAuctionCategoryVm newCategory = new CreateAuctionCategoryVm()
            {
                Name        = "NameCategory",
                Discription = "TestDiscription"
            };

            AuctionManagementService service = new AuctionManagementService();

            service.CreateAuctionCategory(newCategory);
        }
コード例 #2
0
        //добавление категории аукциона
        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);
        }