Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public MSAModel GetMSAById(int msaId)
        {
            var      msa    = _OperationalPortalEntities.MSAs.FirstOrDefault(x => x.MSAID == msaId);
            MSAModel msaObj = Mapper.Map <MSA, MSAModel>(msa);

            return(msaObj);
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        public IHttpActionResult SaveMSA([FromBody] MSAModel msaModel)
        {
            var msa = _msaInfo.SaveMSADetails(msaModel);

            if (msa == null)
            {
                return(NotFound());
            }
            return(Ok(msa));
        }
Exemplo n.º 5
0
        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);
                }
            }
        }