public ActionResult CreateMarriage(FormCollection form, MemberMarriageCreateEditViewModel model) { if (ModelState.IsValid) { try { var memberMarriage = new MemberMarriage(); Mapper.DynamicMap(model, memberMarriage); memberMarriage.SpouseId = model.MarriedToMember ? model.SpouseId : (int?)null; memberProvider.AddMarriage(memberMarriage); return(Json(new AjaxViewModel(true, model, null))); } catch (Exception ex) { return(Json(new AjaxViewModel(false, null, ex.Message))); } } return(View(model)); }