Exemplo n.º 1
0
        public LegalWindow(LegalViewModel vm)
        {
            InitializeComponent();

            _vm = vm;
            this.DataContext = _vm;
        }
Exemplo n.º 2
0
        public ActionResult UpdateLegalClient(LegalViewModel client, int id)
        {
            if (string.IsNullOrEmpty(client.Name))
            {
                ModelState.AddModelError("Name", "Please fill out in the form!");
            }

            if (client.TIN <= 0 || client.TIN > 999999999999)
            {
                ModelState.AddModelError("TIN", "Please fill out in the form(maximum 12 symbol)");
            }

            if (ModelState.IsValid)
            {
                _clientService.UpdateLegalClient(new Model.Client.LegalEntity()
                {
                    ClientId = id,
                    Name     = client.Name,
                    TIN      = client.TIN,
                    Address  = new Model.Address.Address()
                    {
                        Country    = client.Country,
                        City       = client.City,
                        Street     = client.Street,
                        HomeNumber = client.Home
                    }
                });

                return(RedirectToAction("GetLegals"));
            }
            else
            {
                return(View(client));
            }
        }
Exemplo n.º 3
0
        private void LegalHyperlink_Click(object sender, RoutedEventArgs e)
        {
            var vm     = new LegalViewModel();
            var window = new LegalWindow(vm);

            window.Owner = this;
            window.ShowDialog();
        }
Exemplo n.º 4
0
        public ActionResult UpdateLegalClient(int id)
        {
            var client = _clientService.GetLegalClient(id);
            var model  = new LegalViewModel()
            {
                Name    = client.Name,
                TIN     = client.TIN,
                Country = client.Address.Country,
                City    = client.Address.City,
                Street  = client.Address.Street,
                Home    = client.Address.HomeNumber
            };

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult AddLegalClient(LegalViewModel client)
        {
            if (string.IsNullOrWhiteSpace(client.Name))
            {
                ModelState.AddModelError("Name", "Please fill out in the form");
            }

            if (client.TIN <= 0 || client.TIN > 999999999999)
            {
                ModelState.AddModelError("TIN", "Please fill out in the form(maximum 12 symbol)");
            }

            if (ModelState.IsValid)
            {
                var resClient = _clientService.AddClient(1, client.Name);

                if (!resClient.Success)
                {
                    return(View("Error"));
                }

                var resPhysical = _clientService.AddLegalEntity(new Model.Client.LegalEntity()
                {
                    ClientId = (int)resClient.Data["id"],
                    Name     = client.Name,
                    TIN      = client.TIN,
                    Address  = new Model.Address.Address()
                    {
                        Country    = client.Country,
                        City       = client.City,
                        Street     = client.Street,
                        HomeNumber = client.Home
                    }
                });

                if (!resPhysical.Success)
                {
                    return(View("Error"));
                }

                return(RedirectToAction("GetLegals"));
            }
            else
            {
                return(View(client));
            }
        }