public IHttpActionResult GetOpportunity(int oppId) { try { using (MaxMasterDbEntities db = new MaxMasterDbEntities()) { var oppInfo = db.GetOpportunityBasicInfo(oppId).FirstOrDefault(); var oppContacts = db.GetOpportunityContacts(oppId).ToList(); var oppLogInfo = db.GetOpportunityLog(oppId).ToList(); List <OpportunitiesLogModel> oppLogs = new List <OpportunitiesLogModel>(); for (int i = 0; i < oppLogInfo.Count; i++) { OpportunitiesLogModel oppLog = new OpportunitiesLogModel(); oppLog.CreatedDate = oppLogInfo[i].CreatedDate.ToString("dd-MMM-yyyy hh:mm tt"); oppLog.CreatedBy = oppLogInfo[i].CreatedBy; if (oppLogInfo[i].AssignedTo != null) { oppLog.AssignedTo = oppLogInfo[i].AssignedTo.ToString(); } oppLog.Status = oppLogInfo[i].Status; oppLog.Id = oppLogInfo[i].Id; oppLog.Comments = oppLogInfo[i].Comments; //string noHTML = Regex.Replace(oppLogInfo[i].Comments, @"<[^>]+>| ", "").Trim(); //string noHTMLNormalised = Regex.Replace(noHTML, @"\s{2,}", " "); //oppLog.Comments = Regex.Replace(noHTMLNormalised, "<[^>]*>", string.Empty).Trim(); var attachments = db.OpportunityAttachments.Where(x => x.OppLog_Id == oppLog.Id).ToList(); if (attachments.Count > 0) { oppLog.Attachments = attachments.Select(x => x.FileAttachment).ToArray(); } oppLogs.Add(oppLog); } return(Content(HttpStatusCode.OK, new { oppInfo, oppLogs, oppContacts })); } } catch (Exception ex) { new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later")); } }