Exemple #1
0
 public ActionResult TourEdit(ProductFormModel productToEdit, bool continueEditing)
 {
     if (ModelState.IsValid)
     {
         //Mapping to domain
         Product product = Mapper.Map <ProductFormModel, Product>(productToEdit);
         if (String.IsNullOrEmpty(product.Slug))
         {
             product.Slug = StringConvert.ConvertShortName(product.Name);
         }
         //this funcion not update all relationship value.
         _productService.EditProduct(product);
         //update attribute
         foreach (var mapping in product.ProductAttributeMappings)
         {
             _productAttributeMappingService.EditProductAttributeMapping(mapping);
         }
         //update productpicture URL
         foreach (var picture in product.ProductPictureMappings)
         {
             _productPictureMappingService.EditProductPictureMapping(picture);
             _pictureService.EditPicture(picture.Picture);
         }
         return(continueEditing ? RedirectToAction("TourEdit", "Product", new { productId = product.Id })
               : RedirectToAction("Tour", "Product"));
     }
     else
     {
         var listProductCategory = _productCategoryService.GetProductCategories().Where(c => c.Name.Contains("Tour")).ToSelectListItems(-1);
         productToEdit.ListProductCategory = listProductCategory;
         return(View("TourEdit", productToEdit));
     }
 }
 public ActionResult RoomEdit(ProductScheduleFormModel productScheduleToEdit, bool continueEditing)
 {
     if (ModelState.IsValid)
     {
         //Mapping to domain
         ProductSchedule productSchedule = Mapper.Map <ProductScheduleFormModel, ProductSchedule>(productScheduleToEdit);
         //if (String.IsNullOrEmpty(product.Slug))
         //{
         //    product.Slug = StringConvert.ConvertShortName(product.Name);
         //}
         ////this funcion not update all relationship value.
         _productScheduleService.EditProductSchedule(productSchedule);
         //update attribute
         foreach (var mapping in productSchedule.ProductScheduleAttributeMappings)
         {
             _productScheduleAttributeMappingService.EditProductScheduleAttributeMapping(mapping);
         }
         //update productpicture URL
         foreach (var picture in productSchedule.ProductSchedulePictureMappings)
         {
             _productSchedulePictureMappingService.EditProductSchedulePictureMapping(picture);
             _pictureService.EditPicture(picture.Picture);
         }
         return(continueEditing ? RedirectToAction("RoomEdit", "ProductSchedule", new { productScheduleId = productSchedule.Id })
               : RedirectToAction("Room", "ProductSchedule"));
     }
     else
     {
         var listProduct = _productService.GetProducts().Where(p => !p.ProductCategory.Name.Contains("Tour")).ToSelectListItems(-1);
         productScheduleToEdit.ListProduct = listProduct;
         return(View("RoomEdit", productScheduleToEdit));
     }
 }
        public ActionResult Edit(AlbumPhotoFormModel photoModel)
        {
            Product product = Mapper.Map <AlbumPhotoFormModel, Product>(photoModel);

            foreach (var picture in product.ProductPictureMappings)
            {
                _productPictureMappingService.EditProductPictureMapping(picture);
                _pictureService.EditPicture(picture.Picture);
            }
            _productService.EditProduct(product);
            return(RedirectToAction("Index", "AlbumPhoto"));
        }
 public ActionResult Edit(ProductFormModel productToEdit, bool continueEditing)
 {
     if (ModelState.IsValid)
     {
         //Mapping to domain
         Product product = productToEdit.product;
         product.Slug = product.Slug + "-" + product.Id;
         if (productToEdit.CategoryId != 0)
         {
             var obj = _ProductCategoryMappingService.GetProductCategoryMappings().Where(p => p.ProductId == productToEdit.product.Id);
             obj.FirstOrDefault().ProductCategoryId = productToEdit.CategoryId;
             _ProductCategoryMappingService.EditProductCategoryMapping(obj.FirstOrDefault());
         }
         //if (productToEdit.CategoryId2 != 0)
         //{
         //    var obj = _ProductCategoryMappingService.GetProductCategoryMappings().Where(p => p.ProductId == productToEdit.product.Id);
         //    obj.LastOrDefault().ProductCategoryId = productToEdit.CategoryId;
         //    _ProductCategoryMappingService.EditProductCategoryMapping(obj.LastOrDefault());
         //}
         //Product product = Mapper.Map<ProductFormModel, Product>(productToEdit.product);
         if (String.IsNullOrEmpty(product.Slug))
         {
             product.Slug = StringConvert.ConvertShortName(product.Name);
         }
         //this funcion not update all relationship value.
         _productService.EditProduct(product);
         //update attribute
         foreach (var mapping in product.ProductAttributeMappings)
         {
             _productAttributeMappingService.EditProductAttributeMapping(mapping);
         }
         //update productpicture URL
         foreach (var picture in product.ProductPictureMappings)
         {
             _productPictureMappingService.EditProductPictureMapping(picture);
             _pictureService.EditPicture(picture.Picture);
         }
         //add tour relation
         return(continueEditing ? RedirectToAction("Edit", "Product", new { productId = product.Id })
               : RedirectToAction("Index", "Product"));
     }
     else
     {
         var listProductCategory = _productCategoryService.GetProductCategories().ToSelectListItems(-1);
         productToEdit.ListProductCategory = listProductCategory;
         return(RedirectToAction("Edit", new{ productId = productToEdit.product.Id }));
     }
 }
Exemple #5
0
        public ActionResult Edit(ProductFormModel productToEdit, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                //Mapping to domain
                Product product = Mapper.Map <ProductFormModel, Product>(productToEdit);

                product.Slug = StringConvert.ConvertShortName(product.Name) + "-" + product.Id;
                //this funcion not update all relationship value.
                _productService.EditProduct(product);
                //update attribute
                //foreach (var mapping in product.ProductAttributeMappings)
                //{
                //    _productAttributeMappingService.EditProductAttributeMapping(mapping);
                //}
                //update productpicture URL
                foreach (var picture in product.ProductPictureMappings)
                {
                    _productPictureMappingService.EditProductPictureMapping(picture);
                    _pictureService.EditPicture(picture.Picture);
                }
                //add tour relation
                #region [add tour relation]
                //var listProductRelation = _productRelationShipService.GetProductById(product.Id);
                //var item1 = listProductRelation.ToList()[0];
                //var item2 = listProductRelation.ToList()[1];
                //var item3 = listProductRelation.ToList()[2];
                //item1.ProductRelateId = productToEdit.Id1;
                //item2.ProductRelateId = productToEdit.Id2;
                //item3.ProductRelateId = productToEdit.Id3;
                //_productRelationShipService.EditProductRelationship(item1);
                //_productRelationShipService.EditProductRelationship(item2);
                //_productRelationShipService.EditProductRelationship(item3);
                #endregion
                return(continueEditing ? RedirectToAction("Edit", "Product", new { productId = product.Id })
                      : RedirectToAction("Index", "Product"));
            }
            else
            {
                var listProductCategory = _productCategoryService.GetProductCategories().ToSelectListItems(-1);
                productToEdit.ListProductCategory = listProductCategory;
                return(View("Edit", productToEdit));
            }
        }
Exemple #6
0
        public IActionResult Edit(EditPicture model)
        {
            pictures.EditPicture(model.Id, model.Description);

            return(RedirectToAction(nameof(Index), "Pictures", new { id = model.Id }));
        }