public ActionResult UpdatePhysicalClient(PhysicalViewModel client, int id) { if (string.IsNullOrEmpty(client.Name)) { ModelState.AddModelError("Name", "Please fill out in the form!"); } if (ModelState.IsValid) { _clientService.UpdatePhysicalClient(new Model.Client.PhysicalEntity() { ClientId = id, Name = client.Name, PassportNumber = client.Passport, DateOfBirth = client.DateOfBirth, Address = new Model.Address.Address() { Country = client.Country, City = client.City, Street = client.Street, HomeNumber = client.Home } }); return(RedirectToAction("GetPhysicals")); } else { return(View(client)); } }
public ActionResult UpdatePhysicalClient(int id) { var client = _clientService.GetPhysicalClient(id); var model = new PhysicalViewModel() { Name = client.Name, Passport = client.PassportNumber, DateOfBirth = client.DateOfBirth.Value, Country = client.Address.Country, City = client.Address.City, Street = client.Address.Street, Home = client.Address.HomeNumber }; return(View(model)); }
public ActionResult AddPhysicalClient(PhysicalViewModel client) { if (string.IsNullOrWhiteSpace(client.Name)) { ModelState.AddModelError("Name", "Please fill out in the form"); } if (ModelState.IsValid) { var resClient = _clientService.AddClient(2, client.Name); if (!resClient.Success) { return(View("Error")); } var resPhysical = _clientService.AddPhysicalEntity(new Model.Client.PhysicalEntity() { ClientId = (int)resClient.Data["id"], Name = client.Name, PassportNumber = client.Passport, DateOfBirth = client.DateOfBirth, 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("GetPhysicals")); } else { return(View(client)); } }