public async Task <IActionResult> Edit(EditOperatorViewModel model) { IActionResult result; if (ModelState.IsValid) { Address address = await _addresses.FindOrAddAddressAsync( model.Address.Number, model.Address.Street, model.Address.Town, model.Address.County, model.Address.Postcode, model.Address.Country); DateTime doB = DateTime.Parse(model.OperatorDateOfBirth); Operator op = await _operators.UpdateOperatorAsync( model.Operator.Id, model.Operator.FirstNames, model.Operator.Surname, model.Operator.OperatorNumber, model.Operator.FlyerNumber, doB, address.Id); result = RedirectToAction("Index"); } else { result = View(model); } return(result); }
public async Task <IActionResult> Edit(int id) { Operator op = await _operators.GetOperatorAsync(id); EditOperatorViewModel model = new EditOperatorViewModel(); model.Operator = op; model.Address = op.Address; model.OperatorDateOfBirth = op.DoB.ToString("MM/dd/yyyy"); return(View(model)); }