Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            WagonType wagonType = _wagonTypeLogic.GetWagonTypeById(id);
            WagonTypeViewModel wagonTypeViewModel = new WagonTypeViewModel
            {
                Id = wagonType.Id,
                Name = wagonType.Name,
                NumberOfPlaces = wagonType.NumberOfPlaces,
                Coefficient = wagonType.Coefficient
            };

            return View(wagonTypeViewModel);
        }
Exemplo n.º 2
0
        public ActionResult Create(WagonTypeViewModel wagonTypeViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(wagonTypeViewModel);
            }
            #region OLD MAPPING
            //var wagonType = new WagonType
            //{
            //    Id = wagonTypeViewModel.Id,
            //    Name = wagonTypeViewModel.Name,
            //    NumberOfPlaces = wagonTypeViewModel.NumberOfPlaces,
            //    Coefficient = wagonTypeViewModel.Coefficient
            //};
            #endregion
            Mapper.CreateMap<WagonTypeViewModel, WagonType>();
            var wagonType = Mapper.Map<WagonTypeViewModel, WagonType>(wagonTypeViewModel);

            _wagonTypeLogic.AddWagonType(wagonType);

            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
        public ActionResult Edit(WagonTypeViewModel wagonTypeViewModel)
        {
            //клиентская валидация отключена валидировать на сервере
            if (!ModelState.IsValid)
            {
                return View();
            }

            #region OLD MAPPING
            //WagonType wagonType = new WagonType
            //{
            //    Id = wagonTypeViewModel.Id,
            //    Name = wagonTypeViewModel.Name,
            //    NumberOfPlaces = wagonTypeViewModel.NumberOfPlaces,
            //    Coefficient = wagonTypeViewModel.Coefficient
            //};
             #endregion
            Mapper.CreateMap<WagonTypeViewModel, WagonType>();
            var wagonType = Mapper.Map<WagonTypeViewModel, WagonType>(wagonTypeViewModel);

            _wagonTypeLogic.EditWagonType(wagonType);

            return RedirectToAction("Index");
        }