public void Edit_WithCorrectData_ShouldPassSuccessfully()
        {
            string errorMessagePrefix = "ProductsService Edit() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));


            ProductServiceModel productFromDb = context.Products.First().To <ProductServiceModel>();

            ProductServiceModel expectedProduct = productFromDb;

            expectedProduct.Name          = "Edit";
            expectedProduct.Price         = 0.01M;
            expectedProduct.Description   = "TestProductEdit";
            expectedProduct.Specification = "TestProductEdit";


            bool actualResult = this.productsService.Edit(expectedProduct);

            ProductServiceModel actualProduct = context.Products.FirstOrDefault(p => p.Id == productFromDb.Id).To <ProductServiceModel>();

            Assert.True(actualProduct.Name == expectedProduct.Name, errorMessagePrefix + " " + "Name not editted properly.");
            Assert.True(actualProduct.Price == expectedProduct.Price, errorMessagePrefix + " " + "Price not editted properly.");
            Assert.True(actualProduct.Description == expectedProduct.Description, errorMessagePrefix + " " + "Description not editted properly.");
            Assert.True(actualProduct.Specification == expectedProduct.Specification, errorMessagePrefix + " " + "Specification not editted properly.");
            Assert.True(actualResult, errorMessagePrefix);
        }
Esempio n. 2
0
 public ProductModel(ProductServiceModel model)
 {
     this.Id    = model.Id;
     this.Title = model.Title;
     this.Price = model.Price;
     this.MPN   = model.MPN;
 }
        public void Create_WithNonExistentParentCategory_ShouldReturnFalse()
        {
            string errorMessagePrefix = "ProductsService Create() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));

            int nonExistentChildCategoryId = context.ChildCategories.Last().Id + 1;

            ProductServiceModel testProduct = new ProductServiceModel
            {
                Name            = "Lenovo",
                ChildCategoryId = nonExistentChildCategoryId
            };

            int expectedCount = context.ChildCategories.Count();

            bool actualResult = this.productsService.Create(testProduct);
            int  actualCount  = context.ChildCategories.Count();

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 4
0
        public IActionResult Create(ProductCreateInputModel productCreateInputModel)
        {
            if (!this.ModelState.IsValid)
            {
                var childCategories = this.childCategoriesService.GetAllChildCategories();

                this.ViewData["categories"] = childCategories.Select(childCategory => new ProductCreateChildCategoryViewModel
                {
                    Id = childCategory.Id,
                    ParentCategoryName = childCategory.ParentCategory.Name,
                    Name = childCategory.Name,
                })
                                              .ToList();

                return(this.View());
            }

            string pictureUrl = this.cloudinaryService.UploadPicture(
                productCreateInputModel.Image,
                productCreateInputModel.Name);

            ProductServiceModel productServiceModel = AutoMapper.Mapper.Map <ProductServiceModel>(productCreateInputModel);

            productServiceModel.Image = pictureUrl;

            this.productsService.Create(productServiceModel);

            return(this.Redirect("/"));
        }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            var loadingTask = Task.Run(async delegate
            {
                try
                {
                    var productsLoadTask = ProductServiceModel.GetProducts(new ProductQuery
                    {
                        Type           = _partConnector.Type,
                        RevisionFilter = RevisionFilter.All
                    });

                    TaskNotifier = new TaskNotifier(productsLoadTask);

                    var products   = await productsLoadTask;
                    var productVms = products.Select(pm => new ProductInfoViewModel(pm)).OrderBy(p => p.FullIdentifier);

                    await Execute.OnUIThreadAsync(delegate
                    {
                        AvailableProducts = productVms.ToArray();
                        NotifyOfPropertyChange(nameof(AvailableProducts));
                    });
                }
                catch (Exception e)
                {
                    await Execute.OnUIThreadAsync(() => ErrorMessage = e.Message);
                }
            });

            TaskNotifier = new TaskNotifier(loadingTask);
        }
 public IActionResult CreateProductService([FromBody] ProductServiceModel request)
 {
     try {
         User currentUser = _userService.CheckUseRole(_httpContextAccessor.HttpContext.User, menu, "create");
         if (currentUser != null)
         {
             int ledger_code = _context.ChartOfAccounts.Max(t => t.ledger_Code);
             request.created_by   = currentUser.User_Id;
             request.created_date = DateTime.Now;
             ChartOfAccountModel coa = new ChartOfAccountModel();
             coa.Created_by   = currentUser.User_Id;
             coa.Ledger_name  = request.d_name;
             coa.ledger_Code  = ledger_code + 1;
             coa.is_ledger    = false;
             coa.is_subledger = true;
             _context.Add(request);
             _context.Add(coa);
             _context.SaveChanges();
             _eventService.SaveEvent(currentUser.User_Id, EventUserLog.EVENT_CREATE, request.d_name, "ProductService");
             return(Ok(request));
         }
         else
         {
             return(Ok(SendResult.SendError("You don`t have create permision.")));
         }
     } catch (Exception error) {
         Console.WriteLine(error);
         return(BadRequest(SendResult.SendError("You don`t create new ProductService")));
     }
 }
 public IActionResult updateProductService([FromBody] ProductServiceModel request)
 {
     try {
         User currentUser = _userService.CheckUseRole(_httpContextAccessor.HttpContext.User, menu, "update");
         if (currentUser != null)
         {
             ProductServiceModel model = _context.ProductServices.FirstOrDefault(p => p.id == request.id);
             model.p_type    = request.p_type;
             model.p_name    = request.p_name;
             model.d_name    = request.d_name;
             model.p_group   = request.p_group;
             model.qtyonhand = request.qtyonhand;
             model.p_price   = request.p_price;
             model.s_price   = request.s_price;
             model.i_account = request.i_account;
             model.e_account = request.e_account;
             model.reorder   = request.reorder;
             model.barcode   = request.barcode;
             model.istaxable = request.istaxable;
             model.taxtype   = request.taxtype;
             model.status    = request.status;
             model.image     = request.image;
             _context.SaveChanges();
             _eventService.SaveEvent(currentUser.User_Id, EventUserLog.EVENT_UPDATE, request.d_name, "ProductService");
             return(Ok(model));
         }
         else
         {
             return(Ok(SendResult.SendError("You don`t have update permision.")));
         }
     } catch (Exception error) {
         Console.WriteLine(error);
         return(BadRequest(SendResult.SendError("You don`t update ProductService info")));
     }
 }
Esempio n. 8
0
        public async Task <IActionResult> Edit(string id, ProductEditBindingModel productEditBindingModel)
        {
            if (!this.ModelState.IsValid)
            {
                var allProductTypes = await this.productService.GetAllProductTypes().ToListAsync();

                this.ViewData["types"] = allProductTypes
                                         .Select(productType => new ProductEditProductTypeViewModel
                {
                    Name = productType.Name,
                })
                                         .ToList();

                return(this.View(productEditBindingModel));
            }

            string pictureUrl = await this.cloudinaryService
                                .UploadPictureAync(productEditBindingModel.Picture, productEditBindingModel.Name);

            ProductServiceModel productServiceModel = AutoMapper.Mapper.Map <ProductServiceModel>(productEditBindingModel);

            productServiceModel.Picture = pictureUrl;

            await this.productService.Edit(id, productServiceModel);

            return(this.Redirect($"/Product/Details/{id}"));
        }
Esempio n. 9
0
        public async Task <bool> Create(ProductServiceModel productServiceModel)
        {
            //works
            var productType = this.context.ProductTypes.FirstOrDefault(p => p.Name == productServiceModel.ProductType.Name);

            var product = productServiceModel.To <Product>();

            product.ProductType = productType; // THIS IS FOR PREVENTING THE NEW CREATION OF PRODUCT TYPE!
            #region old mapping
            //    new Product
            //{
            //    Name = productServiceModel.Name,
            //    Price = productServiceModel.Price,
            //    ManufacturedOn = productServiceModel.ManufacturedOn,
            //    ProductType=productType,
            //    Picture=productServiceModel.Picture

            //};
            #endregion

            context.Products.Add(product);
            int result = await context.SaveChangesAsync();

            return(result > 0);
        }
        public async Task Edit_WithCorrectData_ShouldEditProductCorrectly()
        {
            string errorMessagePrefix = "ProductService Edit() method does not work properly.";

            var context = StopifyDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.productService = new ProductService(context);

            ProductServiceModel expectedData = context.Products.First().To <ProductServiceModel>();

            expectedData.Name           = "Editted_Name";
            expectedData.Price          = 0.01M;
            expectedData.ManufacturedOn = DateTime.UtcNow;
            expectedData.Picture        = "Editted_Picture";
            expectedData.ProductType    = context.ProductTypes.Last().To <ProductTypeServiceModel>();

            await this.productService.Edit(expectedData.Id, expectedData);

            ProductServiceModel actualData = context.Products.First().To <ProductServiceModel>();

            Assert.True(actualData.Name == expectedData.Name, errorMessagePrefix + " " + "Name not editted properly.");
            Assert.True(actualData.Price == expectedData.Price, errorMessagePrefix + " " + "Price not editted properly.");
            Assert.True(actualData.ManufacturedOn == expectedData.ManufacturedOn, errorMessagePrefix + " " + "Manufactured On not editted properly.");
            Assert.True(actualData.Picture == expectedData.Picture, errorMessagePrefix + " " + "Picture not editted properly.");
            Assert.True(actualData.ProductType.Name == expectedData.ProductType.Name, errorMessagePrefix + " " + "Product Type not editted properly.");
        }
Esempio n. 11
0
        public bool Edit(ProductServiceModel productServiceModel)
        {
            var product = this.context.Products.FirstOrDefault(p => p.Id == productServiceModel.Id);

            if (product == null)
            {
                return(false);
            }

            bool isHaveChildCategory = childCategoriesService.IsHaveChildCategoryWhitId(productServiceModel.ChildCategoryId);


            if (!isHaveChildCategory)
            {
                return(false);
            }

            product.Name            = productServiceModel.Name;
            product.Price           = productServiceModel.Price;
            product.Description     = productServiceModel.Description;
            product.Specification   = productServiceModel.Specification;
            product.Quantity        = productServiceModel.Quantity;
            product.ChildCategoryId = productServiceModel.ChildCategoryId;
            if (!string.IsNullOrEmpty(productServiceModel.Image))
            {
                product.Image = productServiceModel.Image;
            }


            this.context.Products.Update(product);
            int result = context.SaveChanges();

            return(result > 0);
        }
        public async Task <IActionResult> Edit(ProductEditInputModel productEditInputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            ProductServiceModel productServiceModel = productEditInputModel.To <ProductServiceModel>();

            if (productEditInputModel.ImageFormFile != null)
            {
                string pictureUrl = await this.cloudinaryService
                                    .UploadPictureAsync(productEditInputModel.ImageFormFile, productEditInputModel.Name);

                ProductServiceModel productFromDb = await this.productService.EditAsync(productServiceModel);

                await this.imageService.CreateWithProductAsync(pictureUrl, productFromDb.Id);

                return(this.RedirectToAction("All", "Products"));
            }

            await this.productService.EditAsync(productServiceModel);

            return(this.RedirectToAction("All", "Products"));
        }
        public async Task <bool> Edit(string id, ProductServiceModel productServiceModel)
        {
            var productTypeNameFromDb = await this.context.ProductTypes
                                        .FirstOrDefaultAsync(productType => productType.Name == productServiceModel.ProductType.Name);

            if (productTypeNameFromDb == null)
            {
                throw new ArgumentNullException(nameof(productTypeNameFromDb));
            }

            var product = await this.context.Products.FirstOrDefaultAsync(product => product.Id == id);

            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            product.Name           = productServiceModel.Name;
            product.Price          = productServiceModel.Price;
            product.ManufacturedOn = productServiceModel.ManufacturedOn;
            product.Picture        = productServiceModel.Picture;
            product.ProductType    = productTypeNameFromDb;

            this.context.Products.Update(product);
            var result = await this.context.SaveChangesAsync();

            return(result > 0);
        }
Esempio n. 14
0
        public async Task <IActionResult> Create(ProductsCreateInputModel serviceModel)
        {
            if (!ModelState.IsValid)
            {
                await SetProductTypeViewData();

                await SetIngredientsViewData();

                return(this.View(serviceModel));
            }

            string imageUrl = this.cloudinaryServices.UploadeImage(serviceModel.Image, serviceModel.Name);

            var productType = await this.productsServices.GetAllTypes().FirstOrDefaultAsync(pt => pt.Name == serviceModel.ProductType);

            var productServiceModel = AutoMapper.Mapper.Map <ProductsCreateInputServiceModel>(serviceModel);

            productServiceModel.ProductType = productType;

            List <IngredientServiceModel> ingredientServiceModels = await this.ingredientsServices.MapIngNamesToIngredientServiceModel(productServiceModel);

            ProductServiceModel product = new ProductServiceModel
            {
                Name        = serviceModel.Name,
                Ingredients = ingredientServiceModels,
                Description = serviceModel.Description,
                Price       = serviceModel.Price,
                ProductType = productType,
                Image       = imageUrl
            };

            await this.productsServices.Create(product);

            return(this.Redirect(ServicesGlobalConstants.HomeIndex));
        }
Esempio n. 15
0
        public async Task Create_WithCorrectData_ShouldSuccessfullyCreate()
        {
            var errorMsgPrefix = "ProductService Create() method does not work properly.";

            var context = StopifyDbContextInMemoryFactory.InitializeContext();

            SeedData(context);
            this.productService = new ProductService(context);

            var testProductService = new ProductServiceModel
            {
                Name           = "Pesho",
                Price          = 5,
                ManufacturedOn = DateTime.UtcNow,
                Picture        = "src/res/default.png",
                ProductType    = new ProductTypeServiceModel
                {
                    Name = "Television",
                }
            };

            var actualResult = await this.productService.Create(testProductService);

            Assert.True(actualResult, errorMsgPrefix);
        }
Esempio n. 16
0
        public async Task Create_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "ProductService Create(ProductServiceModel) method does not work properly.";

            var context = HealthInsDbContextInMemoryFactory.InitializeContext();

            this.productService = new ProductService(context);
            // await SeedData(context);

            ProductServiceModel newProduct = new ProductServiceModel()
            {
                Id            = 1,
                Idntfr        = "LIFE10",
                Label         = "Life 10",
                FrequencyRule = "MONTHLY",
                MaxAge        = 40,
                MinAge        = 18
            };
            var actualResults = await this.productService.Create(newProduct);

            var actualEntry = this.productService.GetById(1);

            Assert.True(newProduct.Idntfr == actualEntry.Idntfr, errorMessagePrefix + " " + "Idntfr is not returned properly.");
            Assert.True(newProduct.Label == actualEntry.Label, errorMessagePrefix + " " + "Label is not returned properly.");
            Assert.True(newProduct.MaxAge == actualEntry.MaxAge, errorMessagePrefix + " " + "MaxAge is not returned properly.");
            Assert.True(newProduct.MinAge == actualEntry.MinAge, errorMessagePrefix + " " + "MinAge is not returned properly.");
            Assert.True(newProduct.FrequencyRule == actualEntry.FrequencyRule, errorMessagePrefix + " " + "FrequencyRule Type is not returned properly.");
        }
Esempio n. 17
0
        public async Task <bool> Edit(string id, ProductServiceModel product)
        {
            Categorie categorieFromDb = await this.dbContext.Categories.FirstOrDefaultAsync(x => x.Name == product.Categorie);

            if (categorieFromDb == null)
            {
                throw new ArgumentNullException(nameof(categorieFromDb));
            }

            Product productFromDb = await this.dbContext.Products.FirstOrDefaultAsync(x => x.Id == id);

            if (productFromDb == null)
            {
                throw new ArgumentNullException(nameof(productFromDb));
            }

            productFromDb.Model   = product.Model;
            productFromDb.Price   = product.Price;
            productFromDb.Picture = product.Picture;

            productFromDb.Categorie = categorieFromDb;

            this.dbContext.Products.Update(productFromDb);

            int result = await dbContext.SaveChangesAsync();

            return(result > 0);
        }
Esempio n. 18
0
        public IEnumerable <ProductServiceModel> GetShopProducts(ProductServiceModel model)
        {
            var modelProvider = Mapper.Map <Product>(model);
            var list          = Provider.ProductsProvider.GetShopProducts(modelProvider);

            return(Mapper.Map <IEnumerable <ProductServiceModel> >(list));
        }
Esempio n. 19
0
        public async Task Update_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "ProductService Update(ProductServiceModel) method does not work properly.";

            var context = HealthInsDbContextInMemoryFactory.InitializeContext();

            this.productService = new ProductService(context);
            await SeedData(context);

            ProductServiceModel newProduct = context.Products.First().To <ProductServiceModel>();

            newProduct.Idntfr        = "LIFE10";
            newProduct.Label         = "Life 10";
            newProduct.FrequencyRule = "ANNUAL";
            newProduct.MaxAge        = 1;
            newProduct.MinAge        = 2;

            var actualResults = await this.productService.Update(newProduct);

            var actualEntry = this.productService.GetById(newProduct.Id);

            Assert.True(newProduct.Idntfr == actualEntry.Idntfr, errorMessagePrefix + " " + "Idntfr is not returned properly.");
            Assert.True(newProduct.Label == actualEntry.Label, errorMessagePrefix + " " + "Label is not returned properly.");
            Assert.True(newProduct.MaxAge == actualEntry.MaxAge, errorMessagePrefix + " " + "MaxAge is not returned properly.");
            Assert.True(newProduct.MinAge == actualEntry.MinAge, errorMessagePrefix + " " + "MinAge is not returned properly.");
            Assert.True(newProduct.FrequencyRule == actualEntry.FrequencyRule, errorMessagePrefix + " " + "FrequencyRule Type is not returned properly.");
        }
Esempio n. 20
0
        public void Create_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "ProductsService Create() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));

            int childCategoryId = context.ChildCategories.First().Id;

            ProductServiceModel testProduct = new ProductServiceModel
            {
                Name            = "TestProduct",
                ChildCategoryId = childCategoryId
            };

            int expectedCount = context.Products.Count() + 1;

            bool actualResult = this.productsService.Create(testProduct);
            int  actualCount  = context.Products.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 21
0
        public ProductServiceModel GetItem(ProductServiceModel model)
        {
            var modelProvider = Mapper.Map <ProductModelProvider>(model);
            var item          = Provider.ProductsProvider.GetItem(modelProvider);

            return(Mapper.Map <ProductServiceModel>(item));
        }
Esempio n. 22
0
        public async Task <IActionResult> Create(ProductCreateInputModel productCreateInputModel)
        {
            if (!this.ModelState.IsValid)
            {
                var allProductTypes = await this.productService.GetAllProductTypes().ToListAsync();

                this.ViewData["types"] = allProductTypes.Select(productType => new ProductCreateProductTypeViewModel
                {
                    Name = productType.Name
                })
                                         .ToList();;

                return(this.View());
            }

            string pictureUrl = await this.cloudinaryService.UploadPictureAsync(
                productCreateInputModel.Picture,
                productCreateInputModel.Name);

            ProductServiceModel productServiceModel = AutoMapper.Mapper.Map <ProductServiceModel>(productCreateInputModel);

            productServiceModel.Picture = pictureUrl;

            await this.productService.Create(productServiceModel);

            return(this.Redirect("/"));
        }
Esempio n. 23
0
        public async Task <bool> Edit(string id, ProductServiceModel productServiceModel)
        {
            ProductType productTypeFromDb =
                this.context.ProductTypes
                .SingleOrDefault(productType => productType.Name == productServiceModel.ProductType.Name);

            if (productTypeFromDb == null)
            {
                throw new ArgumentNullException(nameof(productTypeFromDb));
            }

            Product productFromDb = await this.context.Products.SingleOrDefaultAsync(product => product.Id == id);

            if (productFromDb == null)
            {
                throw new ArgumentNullException(nameof(productFromDb));
            }

            productFromDb.Name        = productServiceModel.Name;
            productFromDb.Price       = productServiceModel.Price;
            productFromDb.Picture     = productServiceModel.Picture;
            productFromDb.Description = productServiceModel.Description;

            productFromDb.ProductType = productTypeFromDb;

            this.context.Products.Update(productFromDb);
            int result = await this.context.SaveChangesAsync();

            return(result > 0);
        }
        public async Task <bool> UpdateProductAsync(ProductServiceModel serviceModel)
        {
            var oldProduct = await AllProduct.FirstOrDefaultAsync(o => o.Id == serviceModel.Product.Id);

            var productEntry = _context.Entry(oldProduct);

            serviceModel.Product.LastUpdateByUserId = serviceModel.User.Id;
            serviceModel.Product.LastUpdateDate     = DateTime.Now;

            productEntry.CurrentValues.SetValues(serviceModel.Product);

            _context.Entry(oldProduct).Property(o => o.CreateByUserId).IsModified = false;
            _context.Entry(oldProduct).Property(o => o.CreateDate).IsModified     = false;

            foreach (var newDetail in serviceModel.Product.Details)
            {
                var oldDetail = oldProduct.Details.FirstOrDefault(o => o.ForCurrentRequestLanguage());
                if (oldDetail.Language == newDetail.Language)
                {
                    newDetail.Id = oldDetail.Id;
                    _context.Entry(oldDetail).CurrentValues.SetValues(newDetail);
                }
            }

            _context.TryUpdateManyToMany(oldProduct.EntityFiles, serviceModel.Product.EntityFiles, o => o.FileEntityId);
            _context.TryUpdateManyToMany(oldProduct.EntityTaxonomies, serviceModel.Product.EntityTaxonomies, o => o.TaxonomyId);

            var updateResultCount = await _context.SaveChangesAsync();

            return(updateResultCount > 0);
        }
Esempio n. 25
0
        public async Task Create(ProductServiceModel model)
        {
            var product = Mapper.Map <Product>(model);

            await this.context.Products.AddAsync(product);

            await this.context.SaveChangesAsync();
        }
Esempio n. 26
0
        /// <summary>
        /// Update product's information in DB
        /// </summary>
        /// <param name="product"></param>
        /// <returns>result status</returns>
        public async Task <bool> UpdateAsync(ProductServiceModel product)
        {
            var oldProduct = await this.GetProductFromDBAsync(product.Id);

            var updatedProduct = product.UpdateProperties(oldProduct);

            return(await this.productRepository.UpdateAsync(updatedProduct));
        }
Esempio n. 27
0
        public async Task <IActionResult> Details(long Id)
        {
            ProductServiceModel     productFromDB = this.productService.GetById(Id);
            ProductCreateInputModel product       = productFromDB.To <ProductCreateInputModel>();
            var FrequencyList = product.FrequencyRule = productFromDB.FrequencyRule.Split(",").ToList();

            product.FrequencyRule = FrequencyList;
            return(this.View(product));
        }
Esempio n. 28
0
        public async Task <ProductServiceModel> CreateAsync(ProductServiceModel productServiceModel)
        {
            Product product = productServiceModel.To <Product>();

            await this.context.Products.AddAsync(product);

            await this.context.SaveChangesAsync();

            return(product.To <ProductServiceModel>());
        }
        public async Task <BaseJsonResult> Update([FromBody] ProductViewModel viewModel)
        {
            var serviceModel = ProductServiceModel.FromViewModel(viewModel);

            serviceModel.User = CurrentUser;

            await _productService.UpdateProductAsync(serviceModel);

            return(new BaseJsonResult(Base.Properties.Resources.POST_SUCCEEDED, viewModel.EntityId));
        }
Esempio n. 30
0
        public async Task <bool> Create(ProductServiceModel productServiceModel)
        {
            Product product = AutoMapper.Mapper.Map <Product>(productServiceModel);

            product.FrequencyRule = String.Join(" ", productServiceModel.FrequencyRule);
            context.Products.Add(product);
            int result = await context.SaveChangesAsync();

            productServiceModel.Id = product.Id;
            return(result > 0);
        }