Пример #1
0
        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));
        }
Пример #2
0
        // 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("");
        }
Пример #3
0
        // 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("");
        }
Пример #4
0
        // 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));
        }
Пример #5
0
        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);
        }