public JsonResult Add(Form _dpsform) { PortDPSRepository repository; Port_DPS dpsToSave; try { repository = new PortDPSRepository(); if (_dpsform.ID > 0) { //Edit Operation } else { //Add Operation dpsToSave = new Port_DPS(); Mappings.ViewModelToModel(dpsToSave, _dpsform); repository.Add(dpsToSave); } } catch (Exception ex) { } //return _dpsform; return Json(_dpsform, JsonRequestBehavior.AllowGet); }
/// <summary> /// This helps to Map Client side model which is ViewModel to Server side Model(DB Model) /// </summary> /// <param name="dpsToSave"></param> /// <param name="_dpsform"></param> public static void ViewModelToModel(Port_DPS dpsToSave, Form _dpsform) { dpsToSave.DateRec = _dpsform.DateRec; dpsToSave.OrigAcct_ = _dpsform.OriginalAccount; dpsToSave.PIMSAcct_ = _dpsform.PIMSAccount; dpsToSave.Amount = _dpsform.Amount; dpsToSave.Net_Payment = _dpsform.NetPayment; dpsToSave.TransCode = _dpsform.TransCode; dpsToSave.TransDate = _dpsform.TranDate; dpsToSave.OurCheckNumber = _dpsform.OurCheck; dpsToSave.PmtType = _dpsform.PmtTypeId; dpsToSave.TransSource = _dpsform.TransSourceId; dpsToSave.AcctName = _dpsform.Name; dpsToSave.CurrentResp = _dpsform.Responsibility; dpsToSave.Portfolio_ = _dpsform.Portfolio; dpsToSave.Uploaded__y_n_ = _dpsform.Uploaded; dpsToSave.CheckNumber = _dpsform.CheckNumber; }