コード例 #1
0
        public async Task <IActionResult> CreateType(ProductTypeCreateBindingModel productTypeCreateBindingModel)
        {
            ProductTypeServiceModel productTypeServiceModel = productTypeCreateBindingModel.To <ProductTypeServiceModel>();

            await this.productService.CreateProductType(productTypeServiceModel);

            return(this.Redirect("/"));
        }
コード例 #2
0
        public async Task <IActionResult> CreateType(ProductTypeCreateInputModel productTypeCreateInputModel)
        {
            ProductTypeServiceModel productTypeServiceModel = mapper.Map <ProductTypeServiceModel>(productTypeCreateInputModel);

            await this.productService.CreateProductType(productTypeServiceModel);

            return(this.Redirect("/"));
        }
コード例 #3
0
        public async Task <bool> CreateProductType(ProductTypeServiceModel productTypeServiceModel)
        {
            ProductType productType = productTypeServiceModel.To <ProductType>();

            this.context.ProductTypes.Add(productType);
            int result = await this.context.SaveChangesAsync();

            return(result > 0);
        }
コード例 #4
0
        public async Task <bool> CreateProductType(ProductTypeServiceModel productTypeServiceModel)
        {
            ProductType productType = mapper.Map <ProductType>(productTypeServiceModel);

            context.ProductTypes.Add(productType);
            int result = await context.SaveChangesAsync();

            return(result > 0);
        }
コード例 #5
0
        public async Task <bool> CreateProductType(ProductTypeServiceModel productTypeServiceModel)
        {
            var productType = Mapper.Map <ProductType>(productTypeServiceModel);

            await this.context.ProductTypes.AddAsync(productType);

            var result = await this.context.SaveChangesAsync();

            return(result > 0);
        }
コード例 #6
0
        public async Task <IActionResult> CreateType(ProductTypeCreateInputModel model)
        {
            ProductTypeServiceModel productType = new ProductTypeServiceModel
            {
                Name = model.Name
            };

            await this.productService.CreateProductType(productType);

            return(this.Redirect("/"));
        }
コード例 #7
0
        public async Task <bool> CreateProductType(ProductTypeServiceModel productTypeServiceModel)
        {
            ProductType productType = new ProductType
            {
                Name = productTypeServiceModel.Name
            };

            context.ProductTypes.Add(productType);
            int result = await context.SaveChangesAsync();

            return(result > 0);
        }
コード例 #8
0
        public async Task <bool> CreateType(ProductTypeServiceModel inputModel)
        {
            ProductType productType = new ProductType
            {
                Name = inputModel.Name
            };

            await this.context.ProductTypes.AddAsync(productType);

            int result = await this.context.SaveChangesAsync();

            return(result > num);
        }
コード例 #9
0
        public async Task <IActionResult> CreateType(ProductTypesCreateInputModel serviceModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(serviceModel));
            }

            ProductTypeServiceModel product = new ProductTypeServiceModel
            {
                Name = serviceModel.Name,
            };

            await this.productsServices.CreateType(product);

            return(this.Redirect(ServicesGlobalConstants.RedirectProductCreate));
        }
コード例 #10
0
        public async Task <bool> CreateProductType(ProductTypeServiceModel productTypeServiceModel)
        {
            ProductType productType = productTypeServiceModel.To <ProductType>();

            #region old mapping
            //    new ProductType
            //{
            //    Name = productTypeServiceModel.Name
            //};
            #endregion

            context.ProductTypes.Add(productType);
            int result = await context.SaveChangesAsync();

            return(result > 0);
        }
コード例 #11
0
        public async Task CreateProductType_WithCorrectData_ShouldSuccessfullyCreate()
        {
            var errorMsgPrefix = "ProductService CreateProductType() method does not work properly.";

            var context = StopifyDbContextInMemoryFactory.InitializeContext();

            this.productService = new ProductService(context);

            var testProductType = new ProductTypeServiceModel
            {
                Name = "Pesho",
            };

            var actualResult = await this.productService.CreateProductType(testProductType);

            Assert.True(actualResult, errorMsgPrefix);
        }
コード例 #12
0
        public async Task <IActionResult> CreateType(ProductTypeCreateInputModel productTypeCreateInputModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(productTypeCreateInputModel));
            }

            //for one it is not worth it?
            ProductTypeServiceModel productTypeServiceModel = new ProductTypeServiceModel
            {
                Name = productTypeCreateInputModel.Name
            };

            await this.productService.CreateProductType(productTypeServiceModel);

            return(this.Redirect("/"));
        }