public ReportMasterModel GetReportMasterByPrimaryKey(Int64 MasterReport_Id) { ReportMaster result = this.dataContext .ReportsMaster .FirstOrDefault(pk => pk.MasterReport_Id == MasterReport_Id); if (result == null) { return(null); } return(result.CopyToObject(new ReportMasterModel()) as ReportMasterModel); }
public void UpdateReportMaster(ReportMasterModel model) { ReportMaster existing = this.dataContext .ReportsMaster .Where(rx => rx.MasterReport_Id == model.MasterReport_Id) .FirstOrDefault(); if (existing == null) { existing = model.CopyToObject(new ReportMaster()) as ReportMaster; this.dataContext.ReportsMaster.Add(existing); } else { existing = model.CopyToObject(existing) as ReportMaster; } this.dataContext.SaveChanges(); model = existing.CopyToObject(model) as ReportMasterModel; }