public MikeScenarioResultModel PostUpdateMikeScenarioResultDB(MikeScenarioResultModel mikeScenarioResultModel) { string retStr = MikeScenarioResultModelOK(mikeScenarioResultModel); if (!string.IsNullOrEmpty(retStr)) { return(ReturnMikeScenarioResultError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnMikeScenarioResultError(contactOK.Error)); } MikeScenarioResult mikeScenarioResultToUpdate = GetMikeScenarioResultWithMikeScenarioResultIDDB(mikeScenarioResultModel.MikeScenarioResultID); if (mikeScenarioResultToUpdate == null) { return(ReturnMikeScenarioResultError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.MikeScenarioResult))); } TVItemModel tvItemModelMikeScenarioResult = _TVItemService.GetParentTVItemModelWithTVItemIDForLocationDB(mikeScenarioResultModel.MikeScenarioTVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelMikeScenarioResult.Error)) { return(ReturnMikeScenarioResultError(tvItemModelMikeScenarioResult.Error)); } retStr = FillMikeScenarioResult(mikeScenarioResultToUpdate, mikeScenarioResultModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnMikeScenarioResultError(retStr)); } using (TransactionScope ts = new TransactionScope()) { retStr = DoUpdateChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnMikeScenarioResultError(retStr)); } ts.Complete(); } return(GetMikeScenarioResultModelWithMikeScenarioResultIDDB(mikeScenarioResultToUpdate.MikeScenarioResultID)); }
// Check public string MikeScenarioResultModelOK(MikeScenarioResultModel mikeScenarioResultModel) { string retStr = FieldCheckNotZeroInt(mikeScenarioResultModel.MikeScenarioTVItemID, ServiceRes.MikeScenarioTVItemID); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.DBCommandOK(mikeScenarioResultModel.DBCommand); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } return(""); }
// Fill public string FillMikeScenarioResult(MikeScenarioResult mikeScenarioResult, MikeScenarioResultModel mikeScenarioResultModel, ContactOK contactOK) { mikeScenarioResult.DBCommand = (int)mikeScenarioResultModel.DBCommand; mikeScenarioResult.MikeScenarioTVItemID = mikeScenarioResultModel.MikeScenarioTVItemID; mikeScenarioResult.MikeResultsJSON = mikeScenarioResultModel.MikeResultsJSON; mikeScenarioResult.LastUpdateDate_UTC = DateTime.UtcNow; if (contactOK == null) { mikeScenarioResult.LastUpdateContactTVItemID = 2; } else { mikeScenarioResult.LastUpdateContactTVItemID = contactOK.ContactTVItemID; } return(""); }
// Post AppTask // Post Normal public MikeScenarioResultModel PostAddMikeScenarioResultDB(MikeScenarioResultModel mikeScenarioResultModel) { string retStr = MikeScenarioResultModelOK(mikeScenarioResultModel); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnMikeScenarioResultError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnMikeScenarioResultError(contactOK.Error)); } TVItemModel tvItemModelMikeScenarioResult = _TVItemService.GetTVItemModelWithTVItemIDDB(mikeScenarioResultModel.MikeScenarioTVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelMikeScenarioResult.Error)) { return(ReturnMikeScenarioResultError(tvItemModelMikeScenarioResult.Error)); } MikeScenarioResult mikeScenarioResultNew = new MikeScenarioResult(); retStr = FillMikeScenarioResult(mikeScenarioResultNew, mikeScenarioResultModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnMikeScenarioResultError(retStr)); } using (TransactionScope ts = new TransactionScope()) { db.MikeScenarioResults.Add(mikeScenarioResultNew); retStr = DoAddChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnMikeScenarioResultError(retStr)); } ts.Complete(); } return(GetMikeScenarioResultModelWithMikeScenarioResultIDDB(mikeScenarioResultNew.MikeScenarioResultID)); }
public MikeScenarioResultModel GetMikeScenarioResultModelWithMikeScenarioTVItemIDDB(int MikeScenarioTVItemID) { MikeScenarioResultModel mikeScenarioResultModel = (from c in db.MikeScenarioResults let tvText = (from bl in db.TVItemLanguages where bl.Language == (int)LanguageRequest && bl.TVItemID == c.MikeScenarioTVItemID select bl.TVText).FirstOrDefault <string>() where c.MikeScenarioTVItemID == MikeScenarioTVItemID select new MikeScenarioResultModel { Error = "", MikeScenarioResultID = c.MikeScenarioResultID, DBCommand = (DBCommandEnum)c.DBCommand, MikeScenarioTVItemID = c.MikeScenarioTVItemID, MikeScenarioTVText = tvText, MikeResultsJSON = c.MikeResultsJSON, LastUpdateDate_UTC = c.LastUpdateDate_UTC, LastUpdateContactTVItemID = c.LastUpdateContactTVItemID, }).FirstOrDefault <MikeScenarioResultModel>(); if (mikeScenarioResultModel == null) { return(ReturnMikeScenarioResultError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MikeScenarioResult, ServiceRes.MikeScenarioTVItemID, MikeScenarioTVItemID))); } return(mikeScenarioResultModel); }