コード例 #1
0
        public ActionResult Save(ContractorInfoViewModel model)
        {
            if (ModelState.IsValid)
            {
                var contractor = new DtoContractor
                {
                    Id     = model.Id,
                    Name   = model.Name,
                    Phone  = model.Phone,
                    Tariff = model.Tariff
                };

                _contractorService.SaveContractor(contractor);

                return(RedirectToAction("Index"));
            }
            else
            {
                if (model.Id > 0)
                {
                    return(RedirectToAction("Edit", new { contractorId = model.Id }));
                }
                else
                {
                    return(RedirectToAction("Create"));
                }
            }
        }
コード例 #2
0
        public ViewResult Edit(int contractorId)
        {
            var contractorDto = _contractorService.GetContractor(contractorId);

            if (contractorDto != null)
            {
                var model = new ContractorInfoViewModel
                {
                    Id     = contractorDto.Id,
                    Name   = contractorDto.Name,
                    Phone  = contractorDto.Phone,
                    Tariff = contractorDto.Tariff
                };

                ViewBag.Title = "Редактирование данных подрядчика";

                return(View(model));
            }

            return(View("_Error"));
        }
コード例 #3
0
        private void Open_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Contractor == null)
                {
                    Contractor = new Contractor()
                    {
                        City   = new City(),
                        Region = new Region()
                    }
                }
                ;

                if (Contractor.LegalPerson == null)
                {
                    var viewModel = new ContractorInfoViewModel(Contractor, this);

                    var view = new ContractorInfoView(viewModel);

                    view.ShowDialog();

                    OnPropertyChanged("ContractorSignature");
                }
                else
                {
                    var viewModel = new LegalPersonViewModel(Contractor, this);

                    var view = new LegalPersonInfoView(viewModel);

                    view.ShowDialog();

                    OnPropertyChanged("ContractorSignature");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        public ContractorInfoView(ContractorInfoViewModel contractorInfoViewModel)
        {
            InitializeComponent();

            DataContext = contractorInfoViewModel;
        }