コード例 #1
0
        // GET: Category
        public ActionResult Index()
        {
            var listCategories          = _getCategoriesListQuery.GetAll();
            var listCategoriesViewModel = MappingUtility.MappFromCategoriesBOToCategoriesViewModel(listCategories);

            return(View(listCategoriesViewModel));
        }
コード例 #2
0
        private ProdutCreationViewModel LoadCategories()
        {
            var ProdutViewModel         = new ProdutCreationViewModel();
            var listCategories          = _getCategoriesListQuery.GetAll();
            var listCategoriesViewModel = MappingUtility.MappFromCategoriesBOToCategoriesViewModel(listCategories);

            ProdutViewModel.ListCategories = listCategoriesViewModel;
            return(ProdutViewModel);
        }
コード例 #3
0
        public ActionResult GetDataProduct()
        {
            var ListProductViewModel = new List <ProdutCreationViewModel>();
            var ListProducts         = _productsQuery.GetAllProducts();

            if (((List <Product>)ListProducts).Count == 0)
            {
                return(PartialView("ProductDataList", ListProductViewModel));
            }
            var ListProductEntityViewModel = MappingUtility.MappFromProductViewModelToProduct(ListProducts);

            return(PartialView("ProductDataList", ListProductEntityViewModel));
        }
コード例 #4
0
        public ActionResult IndexProduct()
        {
            var ListProductViewModel = new List <ProdutCreationViewModel>();
            var ListProducts         = _productsQuery.GetAllProducts();

            if (((List <Product>)ListProducts).Count == 0)
            {
                return(View(ListProductViewModel));
            }
            List <ProdutCreationViewModel> ListProductEntityViewModel = MappingUtility.MappFromProductViewModelToProduct(ListProducts);

            return(View(ListProductEntityViewModel));
        }
コード例 #5
0
        // GET: Gender
        public ActionResult Index()
        {
            var ListGenderViewModel = new List <GenderViewModel>();
            var ListGender          = _getGenderListQuery.GetAllGender();

            if (((List <Gender>)ListGender).Count == 0)
            {
                return(View(ListGenderViewModel));
            }

            var ListGenderEntityViewModel = MappingUtility.MappFromGenderBOToGenderViewModel(ListGender);

            return(View(ListGenderEntityViewModel));
        }
コード例 #6
0
        public ActionResult Create(ProdutCreationViewModel product)
        {
            try
            {
                LoadGender();
                ViewBag.ListCategories = LoadCategories();
                product.Gender         = GetGenderById(product.IdGender);
                string filePath = string.Empty;
                if (ModelState.IsValid)
                {
                    var saveFile = _saleFilesFromRequest.SaveFile(Request, Server.MapPath("~/Images/").ToString(), product);
                    filePath = ValidationPath(product, saveFile);
                    var productBussines = MappingUtility.MappFromProductViewToProductBO(product);
                    _commandProduct.AddProduct(productBussines);
                    //hub
                    ProductHub.ProductData();
                    ViewBag.Message = "Product created success";
                }
                else
                {
                    throw new NoValidaDataException("The form is not right please check it again");
                }


                return(View(LoadCategories()));
            }
            catch (FilesRequestFailedException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(LoadCategories()));
            }
            catch (NotValidExtentionException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(LoadCategories()));
            }
            catch (NoValidaDataException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(LoadCategories()));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "Ups something it's wrong please try again later";
                return(View(LoadCategories()));
            }
        }
コード例 #7
0
        public ActionResult Create(CategoriesViewModel categories)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var category = MappingUtility.MappFromCategoryViewModelToCategoryBO(categories);
                    _createCategoryCommand.AddCategory(category);
                }
                else
                {
                    return(View());
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
コード例 #8
0
        private void ReadNewSaves()
        {
            if (_currentSharedMappings == null)
            {
                return;
            }
            if (!MappingUtility.ValidateLocalMappingProfile(_currentLocalMappingProfile))
            {
                _currentLocalMappingProfile = new LocalMappingProfile()
                {
                    LocalMappings = new List <LocalMapping>()
                }
            }
            ;

            var updatedMappings = _mappingManager.CompareLocalToSharedMappings(_currentLocalMappingProfile, _currentSharedMappings);

            if (!updatedMappings.Any())
            {
                return;
            }
            _messages.NewSavesMessage(updatedMappings);
        }
    }
コード例 #9
0
        public ActionResult Create(GenderViewModel gender)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var genderBussines = MappingUtility.MappFromGenderViewModelToGenderBO(gender);
                    if (genderBussines != null)
                    {
                        _createGenderCommand.AddGender(genderBussines);
                    }
                    else
                    {
                        throw new MappingFailedException("The Gender mapping failed");
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }