public string SaveMSADetails(MSAModel msaModel) { string result = string.Empty; try { MSA msa = _OperationalPortalEntities.MSAs.FirstOrDefault(x => x.MSAID == msaModel.MSAID); if (msa != null) { Mapper.Map(msaModel, msa); result = "MSA Updated Successfully"; } else { msa = new MSA(); Mapper.Map(msaModel, msa); msa.Customer = null; _OperationalPortalEntities.MSAs.Add(msa); result = "MSA Saved Successfully"; } _OperationalPortalEntities.SaveChanges(); } catch (Exception ex) { result = ex.Message.ToString(); } return(result); }
public MSAModel GetMSAById(int msaId) { var msa = _OperationalPortalEntities.MSAs.FirstOrDefault(x => x.MSAID == msaId); MSAModel msaObj = Mapper.Map <MSA, MSAModel>(msa); return(msaObj); }
public IActionResult MSA(MSAModel msa) { //string strDoc = @"C:\Users\jakmoz01\Documents\MSADocumentBuilder\SampleMSA.docx"; var dir = _env.WebRootPath; String strDoc = dir + "\\Documents\\SampleMSA.docx"; SearchAndReplace(strDoc, msa); return(View()); }
public IHttpActionResult SaveMSA([FromBody] MSAModel msaModel) { var msa = _msaInfo.SaveMSADetails(msaModel); if (msa == null) { return(NotFound()); } return(Ok(msa)); }
static void SearchAndReplace(string document, MSAModel msa) { using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) { string docText = null; using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream())) { docText = sr.ReadToEnd(); } Regex regexText = new Regex("Insert Date"); docText = regexText.Replace(docText, msa.msaDate); using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create))) { sw.Write(docText); } } }