public HelpDocModel GetHelpDocModelWithDocKeyAndLanguageDB(string DocKey, LanguageEnum Language) { HelpDocModel helpDocModel = (from c in db.HelpDocs where c.DocKey == DocKey && c.Language == (int)Language select new HelpDocModel { Error = "", HelpDocID = c.HelpDocID, DBCommand = (DBCommandEnum)c.DBCommand, DocKey = c.DocKey, Language = (LanguageEnum)c.Language, DocHTMLText = c.DocHTMLText, LastUpdateDate_UTC = c.LastUpdateDate_UTC, LastUpdateContactTVItemID = c.LastUpdateContactTVItemID, }).FirstOrDefault <HelpDocModel>(); if (helpDocModel == null) { return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.HelpDoc, ServiceRes.DocKey + "," + ServiceRes.Language, DocKey + "," + Language))); } return(helpDocModel); }
// Check public string HelpDocModelOK(HelpDocModel helpDocModel) { string retStr = FieldCheckNotNullAndMinMaxLengthString(helpDocModel.DocKey, ServiceRes.DocKey, 3, 100); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.LanguageOK(helpDocModel.Language); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = FieldCheckIfNotNullMaxLengthString(helpDocModel.DocHTMLText, ServiceRes.DocHTMLText, 50000); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.DBCommandOK(helpDocModel.DBCommand); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } return(""); }
public HelpDocModel PostAddHelpDocDB(HelpDocModel helpDocModel) { string retStr = HelpDocModelOK(helpDocModel); if (!string.IsNullOrEmpty(retStr)) { return(ReturnError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } HelpDocModel helpDocModelExist = GetHelpDocModelWithDocKeyAndLanguageDB(helpDocModel.DocKey, helpDocModel.Language); if (string.IsNullOrWhiteSpace(helpDocModelExist.Error)) { return(ReturnError(string.Format(ServiceRes._AlreadyExists, ServiceRes.HelpDoc))); } HelpDoc helpDocNew = new HelpDoc(); retStr = FillHelpDoc(helpDocNew, helpDocModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } using (TransactionScope ts = new TransactionScope()) { db.HelpDocs.Add(helpDocNew); retStr = DoAddChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } LogModel logModel = _LogService.PostAddLogForObj("HelpDocs", helpDocNew.HelpDocID, LogCommandEnum.Add, helpDocNew); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } ts.Complete(); } return(GetHelpDocModelWithHelpDocIDDB(helpDocNew.HelpDocID)); }
// Post public HelpDocModel PostAddOrModifyHelpDocDB(string DocKey, string LanguageText, string DocHTMLText) { ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } LanguageEnum Language = LanguageEnum.en; if (LanguageText == "fr") { Language = LanguageEnum.fr; } HelpDocModel helpDocModelRet = new HelpDocModel(); HelpDocModel helpDocModelExist = GetHelpDocModelWithDocKeyAndLanguageDB(DocKey, Language); if (!string.IsNullOrWhiteSpace(helpDocModelExist.Error)) { HelpDocModel helpDocModelNew = new HelpDocModel() { DBCommand = DBCommandEnum.Original, DocKey = DocKey, DocHTMLText = DocHTMLText, Language = Language, }; helpDocModelRet = PostAddHelpDocDB(helpDocModelNew); if (!string.IsNullOrWhiteSpace(helpDocModelRet.Error)) { return(ReturnError(helpDocModelRet.Error)); } } else { helpDocModelExist.DocHTMLText = DocHTMLText; helpDocModelRet = PostUpdateHelpDocDB(helpDocModelExist); if (!string.IsNullOrWhiteSpace(helpDocModelRet.Error)) { return(ReturnError(helpDocModelRet.Error)); } } return(GetHelpDocModelWithHelpDocIDDB(helpDocModelRet.HelpDocID)); }
public HelpDocModel PostUpdateHelpDocDB(HelpDocModel helpDocModel) { string retStr = HelpDocModelOK(helpDocModel); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } HelpDoc helpDocToUpdate = GetHelpDocWithHelpDocIDDB(helpDocModel.HelpDocID); if (helpDocToUpdate == null) { return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.HelpDoc))); } retStr = FillHelpDoc(helpDocToUpdate, helpDocModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } using (TransactionScope ts = new TransactionScope()) { retStr = DoUpdateChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } LogModel logModel = _LogService.PostAddLogForObj("HelpDocs", helpDocToUpdate.HelpDocID, LogCommandEnum.Change, helpDocToUpdate); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } ts.Complete(); } return(GetHelpDocModelWithHelpDocIDDB(helpDocToUpdate.HelpDocID)); }
public PartialViewResult _HelpDocViewAndEdit(string DocKey, string Title) { ViewBag.HelpDocModelEN = null; ViewBag.HelpDocModelFR = null; ViewBag.Title = Title; ViewBag.DocKey = DocKey; HelpDocModel helpDocModelEN = _HelpDocService.GetHelpDocModelWithDocKeyAndLanguageDB(DocKey, LanguageEnum.en); ViewBag.HelpDocModelEN = helpDocModelEN; HelpDocModel helpDocModelFR = _HelpDocService.GetHelpDocModelWithDocKeyAndLanguageDB(DocKey, LanguageEnum.fr); ViewBag.HelpDocModelFR = helpDocModelFR; return(PartialView()); }
// Fill public string FillHelpDoc(HelpDoc helpDocNew, HelpDocModel helpDocModel, ContactOK contactOK) { helpDocNew.DBCommand = (int)helpDocModel.DBCommand; helpDocNew.DocKey = helpDocModel.DocKey; helpDocNew.Language = (int)helpDocModel.Language; helpDocNew.DocHTMLText = helpDocModel.DocHTMLText; helpDocNew.LastUpdateDate_UTC = DateTime.UtcNow; if (contactOK == null) { helpDocNew.LastUpdateContactTVItemID = 2; } else { helpDocNew.LastUpdateContactTVItemID = contactOK.ContactTVItemID; } return(""); }
public JsonResult HelpDocSaveJSON(string DocKey, string Language, string DocHTMLText) { HelpDocModel HelpDocModel = _HelpDocService.PostAddOrModifyHelpDocDB(DocKey, Language, DocHTMLText); return(Json(HelpDocModel.Error, JsonRequestBehavior.AllowGet)); }