Exemple #1
0
        public ActionResult Update(ManifacturerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                Helpers.InvalidModelState(ModelState);
            }

            _manifacturerService.Update(model);
            return(Json(true));
        }
Exemple #2
0
        public static ManifacturerViewModel MapToViewModel(this Manifacturer manifacturer)
        {
            var viewModel = new ManifacturerViewModel();

            viewModel.Id      = manifacturer.Id;
            viewModel.Name    = manifacturer.Name;
            viewModel.City    = manifacturer.City;
            viewModel.Country = manifacturer.Country;
            viewModel.Address = manifacturer.Address;

            return(viewModel);
        }
Exemple #3
0
        public void Update(ManifacturerViewModel model)
        {
            _unitOfWork.BeginTransaction();

            var manifacturer = _manifacturerRepository.GetById(model.Id);

            if (manifacturer == null)
            {
                _unitOfWork.Commit();
                throw new Exception(ExceptionMessages.ManifacturerException.NOT_FOUND);
            }

            manifacturer.Address = model.Address;
            manifacturer.Country = model.Country;
            manifacturer.City    = model.City;
            manifacturer.Name    = model.Name;



            _manifacturerRepository.Update(manifacturer);
            _unitOfWork.Commit();
        }