Пример #1
0
        public ActionResult EditMarriage(FormCollection form, MemberMarriageCreateEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var memberMarriage = new MemberMarriage();

                    model.MarriedToMember = model.SpouseId != 0;

                    Mapper.DynamicMap(model, memberMarriage);
                    memberMarriage.SpouseId = model.MarriedToMember ? model.SpouseId : (int?)null;
                    memberProvider.UpdateMarriage(memberMarriage);
                    return(Json(new AjaxViewModel(true, model, null)));
                }
                catch (Exception ex)
                {
                    return(Json(new AjaxViewModel(false, null, ex.Message)));
                }
            }
            return(View(model));
        }