public void MWQMSiteStartEndDateService_PostDeleteMWQMSiteStartEndDateDB_IsContactOK_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        string ErrorText = "ErrorText";
                        shimMWQMSiteStartEndDateService.IsContactOK = () =>
                        {
                            return(new ContactOK()
                            {
                                Error = ErrorText
                            });
                        };

                        MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = mwqmSiteStartEndDateService.PostDeleteMWQMSiteStartEndDateDB(mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID);
                        Assert.AreEqual(ErrorText, mwqmSiteStartEndDateModelRet2.Error);
                    }
                }
            }
        }
        public void MWQMSiteStartEndDateService_MWQMSiteStartEndDateAddOrModifyDB_Modify_PostAddMWQMSiteStartEndDateDB_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();

                    FormCollection fc = GetFormCollectionForMWQMSiteStartEndDateAddOrModifyDB();
                    fc["MWQMSiteStartEndDateID"] = mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID.ToString();

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        string ErrorText = "ErrorText";
                        shimMWQMSiteStartEndDateService.PostUpdateMWQMSiteStartEndDateDBMWQMSiteStartEndDateModel = (a) =>
                        {
                            return(new MWQMSiteStartEndDateModel()
                            {
                                Error = ErrorText
                            });
                        };

                        MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = mwqmSiteStartEndDateService.MWQMSiteStartEndDateAddOrModifyDB(fc);
                        Assert.AreEqual(ErrorText, mwqmSiteStartEndDateModelRet2.Error);
                    }
                }
            }
        }
        public void MWQMSiteStartEndDateService_PostUpdateMWQMSiteStartEndDateDB_DoUpdateChanges_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        string ErrorText = "ErrorText";
                        shimMWQMSiteStartEndDateService.DoUpdateChanges = () =>
                        {
                            return(ErrorText);
                        };

                        MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = UpdateMWQMSiteStartEndDateModel(mwqmSiteStartEndDateModelRet);
                        Assert.AreEqual(ErrorText, mwqmSiteStartEndDateModelRet2.Error);
                    }
                }
            }
        }
        public void MWQMSiteStartEndDateService_PostUpdateMWQMSiteStartEndDateDB_GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateIDDB_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        //string ErrorText = "ErrorText";
                        shimMWQMSiteStartEndDateService.GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateIDDBInt32 = (a) =>
                        {
                            return(null);
                        };

                        MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = UpdateMWQMSiteStartEndDateModel(mwqmSiteStartEndDateModelRet);
                        Assert.AreEqual(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.MWQMSiteStartEndDate), mwqmSiteStartEndDateModelRet2.Error);
                    }
                }
            }
        }
        public void MWQMSiteStartEndDateService_FillMWQMSiteStartEndDate_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    mwqmSiteStartEndDateModelNew.MWQMSiteTVItemID = mwqmSiteStartEndDateModelRet.MWQMSiteTVItemID;
                    FillMWQMSiteStartEndDateModel(mwqmSiteStartEndDateModelNew);

                    ContactOK contactOK = mwqmSiteStartEndDateService.IsContactOK();

                    string retStr = mwqmSiteStartEndDateService.FillMWQMSiteStartEndDate(mwqmSiteStartEndDate, mwqmSiteStartEndDateModelNew, contactOK);
                    Assert.AreEqual("", retStr);
                    Assert.AreEqual(contactOK.ContactTVItemID, mwqmSiteStartEndDate.LastUpdateContactTVItemID);

                    contactOK = null;

                    retStr = mwqmSiteStartEndDateService.FillMWQMSiteStartEndDate(mwqmSiteStartEndDate, mwqmSiteStartEndDateModelNew, contactOK);
                    Assert.AreEqual("", retStr);
                    Assert.AreEqual(contactModelListGood[0].ContactTVItemID, mwqmSiteStartEndDate.LastUpdateContactTVItemID);
                }
            }
        }
Example #6
0
        public MWQMSiteStartEndDateModel GetMWQMSiteStartEndDateExistDB(MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel)
        {
            MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = (from c in db.MWQMSiteStartEndDates
                                                                      where c.MWQMSiteTVItemID == mwqmSiteStartEndDateModel.MWQMSiteTVItemID &&
                                                                      c.StartDate == mwqmSiteStartEndDateModel.StartDate
                                                                      select new MWQMSiteStartEndDateModel
            {
                Error = "",
                MWQMSiteStartEndDateID = c.MWQMSiteStartEndDateID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                MWQMSiteTVItemID = c.MWQMSiteTVItemID,
                StartDate = c.StartDate,
                EndDate = c.EndDate,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).FirstOrDefault <MWQMSiteStartEndDateModel>();

            if (mwqmSiteStartEndDateModelRet == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MWQMSiteStartEndDate,
                                                 ServiceRes.MWQMSiteTVItemID + "," +
                                                 ServiceRes.Year + "," +
                                                 ServiceRes.Month + "," +
                                                 ServiceRes.Day + ",",
                                                 mwqmSiteStartEndDateModel.MWQMSiteTVItemID.ToString() + "," +
                                                 mwqmSiteStartEndDateModel.StartDate.Year.ToString() + "," +
                                                 mwqmSiteStartEndDateModel.StartDate.Month.ToString() + "," +
                                                 mwqmSiteStartEndDateModel.StartDate.Day.ToString() + ",")));
            }

            return(mwqmSiteStartEndDateModel);
        }
Example #7
0
        // Check
        public string MWQMSiteStartEndDateModelOK(MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel)
        {
            string retStr = FieldCheckNotZeroInt(mwqmSiteStartEndDateModel.MWQMSiteTVItemID, ServiceRes.MWQMSiteTVItemID);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            retStr = FieldCheckNotNullDateTime(mwqmSiteStartEndDateModel.StartDate, ServiceRes.StartDate);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            if (mwqmSiteStartEndDateModel.EndDate != null)
            {
                if (mwqmSiteStartEndDateModel.StartDate > mwqmSiteStartEndDateModel.EndDate)
                {
                    return(string.Format(ServiceRes._IsLaterThan_, ServiceRes.StartDate, ServiceRes.EndDate));
                }
            }

            retStr = _BaseEnumService.DBCommandOK(mwqmSiteStartEndDateModel.DBCommand);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            return("");
        }
        public void MWQMSiteStartEndDateService_PostAddMWQMSiteStartEndDateDB_GetTVItemModelWithTVItemIDForLocationDB_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        string ErrorText = "ErrorText";
                        shimTVItemService.GetTVItemModelWithTVItemIDDBInt32 = (a) =>
                        {
                            return(new TVItemModel()
                            {
                                Error = ErrorText
                            });
                        };

                        mwqmSiteStartEndDateModelRet = mwqmSiteStartEndDateService.PostAddMWQMSiteStartEndDateDB(mwqmSiteStartEndDateModelRet);
                        Assert.AreEqual(ErrorText, mwqmSiteStartEndDateModelRet.Error);
                    }
                }
            }
        }
Example #9
0
        public MWQMSiteStartEndDateModel PostAddMWQMSiteStartEndDateDB(MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel)
        {
            string retStr = MWQMSiteStartEndDateModelOK(mwqmSiteStartEndDateModel);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            TVItemModel tvItemModelExist = _TVItemService.GetTVItemModelWithTVItemIDDB(mwqmSiteStartEndDateModel.MWQMSiteTVItemID);

            if (!string.IsNullOrWhiteSpace(tvItemModelExist.Error))
            {
                return(ReturnError(tvItemModelExist.Error));
            }

            MWQMSiteStartEndDateModel MWQMSiteStartEndDateModelExist = GetMWQMSiteStartEndDateExistDB(mwqmSiteStartEndDateModel);

            if (string.IsNullOrWhiteSpace(MWQMSiteStartEndDateModelExist.Error))
            {
                return(ReturnError(string.Format(ServiceRes._AlreadyExists, ServiceRes.MWQMSiteStartEndDate)));
            }

            MWQMSiteStartEndDate mwqmSiteStartEndDateNew = new MWQMSiteStartEndDate();

            retStr = FillMWQMSiteStartEndDate(mwqmSiteStartEndDateNew, mwqmSiteStartEndDateModel, contactOK);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            using (TransactionScope ts = new TransactionScope())
            {
                db.MWQMSiteStartEndDates.Add(mwqmSiteStartEndDateNew);
                retStr = DoAddChanges();
                if (!string.IsNullOrWhiteSpace(retStr))
                {
                    return(ReturnError(retStr));
                }

                LogModel logModel = _LogService.PostAddLogForObj("MWQMSiteStartEndDates", mwqmSiteStartEndDateNew.MWQMSiteStartEndDateID, LogCommandEnum.Add, mwqmSiteStartEndDateNew);
                if (!string.IsNullOrWhiteSpace(logModel.Error))
                {
                    return(ReturnError(logModel.Error));
                }

                ts.Complete();
            }
            return(GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB(mwqmSiteStartEndDateNew.MWQMSiteStartEndDateID));
        }
 private void FillMWQMSiteStartEndDateModel(MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel)
 {
     mwqmSiteStartEndDateModel.MWQMSiteTVItemID = mwqmSiteStartEndDateModel.MWQMSiteTVItemID;
     mwqmSiteStartEndDateModel.StartDate        = randomService.RandomDateTime();
     mwqmSiteStartEndDateModel.EndDate          = mwqmSiteStartEndDateModel.StartDate.AddYears(3);
     Assert.IsTrue(mwqmSiteStartEndDateModel.MWQMSiteTVItemID != 0);
     Assert.IsTrue(mwqmSiteStartEndDateModel.StartDate != null);
     Assert.IsTrue(mwqmSiteStartEndDateModel.EndDate != null);
 }
        public void SetupTest(ContactModel contactModelToDo, CultureInfo culture)
        {
            Thread.CurrentThread.CurrentCulture   = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            contactModel = contactModelToDo;
            user         = new GenericPrincipal(new GenericIdentity(contactModel.LoginEmail, "Forms"), null);
            mwqmSiteStartEndDateService = new MWQMSiteStartEndDateService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user);
            testDBService = new TestDBService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user, TableName, Plurial);
            randomService = new RandomService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), user);
            mwqmSiteStartEndDateModelNew = new MWQMSiteStartEndDateModel();
            mwqmSiteStartEndDate         = new MWQMSiteStartEndDate();
        }
        public void MWQMSiteStartEndDateService_PostAddMWQMSiteStartEndDateDB_Good_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);
                }
            }
        }
        public void MWQMSiteStartEndDateService_ReturnError_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    string ErrorText = "ErrorText";
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = mwqmSiteStartEndDateService.ReturnError(ErrorText);
                    Assert.AreEqual(ErrorText, mwqmSiteStartEndDateModelRet.Error);
                }
            }
        }
        public void MWQMSiteStartEndDateService_MWQMSiteStartEndDateAddOrModifyDB_Add_Good_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    FormCollection fc = GetFormCollectionForMWQMSiteStartEndDateAddOrModifyDB();

                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = mwqmSiteStartEndDateService.MWQMSiteStartEndDateAddOrModifyDB(fc);
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);
                }
            }
        }
        public MWQMSiteStartEndDateModel UpdateMWQMSiteStartEndDateModel(MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel)
        {
            FillMWQMSiteStartEndDateModel(mwqmSiteStartEndDateModel);

            MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = mwqmSiteStartEndDateService.PostUpdateMWQMSiteStartEndDateDB(mwqmSiteStartEndDateModel);

            if (!string.IsNullOrWhiteSpace(mwqmSiteStartEndDateModelRet2.Error))
            {
                return(mwqmSiteStartEndDateModelRet2);
            }

            CompareMWQMSiteStartEndDateModels(mwqmSiteStartEndDateModel, mwqmSiteStartEndDateModelRet2);

            return(mwqmSiteStartEndDateModelRet2);
        }
        public void MWQMSiteStartEndDateService_PostAddMWQMSiteStartEndDateDB_UserEmailNotValidated_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    SetupTest(contactModelListGood[2], culture);

                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual(ServiceRes.EmailRequiresValidation, mwqmSiteStartEndDateModelRet.Error);
                }
            }
        }
        public void MWQMSiteStartEndDateService_MWQMSiteStartEndDateAddOrModifyDB_Add_EndDateDay_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    FormCollection fc = GetFormCollectionForMWQMSiteStartEndDateAddOrModifyDB();
                    fc["EndDateDay"] = "0";

                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = mwqmSiteStartEndDateService.MWQMSiteStartEndDateAddOrModifyDB(fc);
                    Assert.AreEqual(string.Format(ServiceRes._IsRequired, ServiceRes.EndDateDay), mwqmSiteStartEndDateModelRet.Error);
                }
            }
        }
        public void MWQMSiteStartEndDateService_MWQMSiteStartEndDateAddOrModifyDB_Add_EndDate_not_null_and_Smaller_StartDate_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    FormCollection fc = GetFormCollectionForMWQMSiteStartEndDateAddOrModifyDB();
                    fc["EndDateYear"] = (int.Parse(fc["StartDateYear"]) - 1).ToString();

                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = mwqmSiteStartEndDateService.MWQMSiteStartEndDateAddOrModifyDB(fc);
                    Assert.AreEqual(string.Format(ServiceRes._IsLaterThan_, ServiceRes.StartDate, ServiceRes.EndDate), mwqmSiteStartEndDateModelRet.Error);
                }
            }
        }
Example #19
0
        public MWQMSiteStartEndDateModel PostUpdateMWQMSiteStartEndDateDB(MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel)
        {
            string retStr = MWQMSiteStartEndDateModelOK(mwqmSiteStartEndDateModel);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            MWQMSiteStartEndDate mwqmSiteStartEndDateToUpdate = GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateIDDB(mwqmSiteStartEndDateModel.MWQMSiteStartEndDateID);

            if (mwqmSiteStartEndDateToUpdate == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.MWQMSiteStartEndDate)));
            }

            retStr = FillMWQMSiteStartEndDate(mwqmSiteStartEndDateToUpdate, mwqmSiteStartEndDateModel, 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("MWQMSiteStartEndDates", mwqmSiteStartEndDateToUpdate.MWQMSiteStartEndDateID, LogCommandEnum.Change, mwqmSiteStartEndDateToUpdate);
                if (!string.IsNullOrWhiteSpace(logModel.Error))
                {
                    return(ReturnError(logModel.Error));
                }

                ts.Complete();
            }
            return(GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB(mwqmSiteStartEndDateToUpdate.MWQMSiteStartEndDateID));
        }
        public void MWQMSiteStartEndDateService_GetMWQMSiteStartEndDateModelCount_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    int mwqmSiteStartEndDateCount = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateModelCountDB();
                    Assert.AreEqual(testDBService.Count + 1, mwqmSiteStartEndDateCount);

                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = mwqmSiteStartEndDateService.PostDeleteMWQMSiteStartEndDateDB(mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID);
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet2.Error);
                }
            }
        }
        public void MWQMSiteStartEndDateService_GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet2 = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB(mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID);
                    Assert.AreEqual(mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID, mwqmSiteStartEndDateModelRet2.MWQMSiteStartEndDateID);

                    int MWQMSiteStartEndDateID = 0;
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet3 = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB(MWQMSiteStartEndDateID);
                    Assert.AreEqual(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MWQMSiteStartEndDate, ServiceRes.MWQMSiteStartEndDateID, MWQMSiteStartEndDateID), mwqmSiteStartEndDateModelRet3.Error);
                }
            }
        }
        public void MWQMSiteStartEndDateService_GetMWQMSiteStartEndDateModelListWithMWQMSiteTVItemIDDB_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    List <MWQMSiteStartEndDateModel> mwqmSiteStartEndDateModelList = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateModelListWithMWQMSiteTVItemIDDB(mwqmSiteStartEndDateModelRet.MWQMSiteTVItemID);
                    Assert.IsTrue(mwqmSiteStartEndDateModelList.Count > 0);

                    int MWQMSiteTVItemID = 0;
                    mwqmSiteStartEndDateModelList = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateModelListWithMWQMSiteTVItemIDDB(MWQMSiteTVItemID);
                    Assert.IsTrue(mwqmSiteStartEndDateModelList.Count == 0);
                }
            }
        }
        public void MWQMSiteStartEndDateService_GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateIDDB_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                    Assert.AreEqual("", mwqmSiteStartEndDateModelRet.Error);

                    MWQMSiteStartEndDate mwqmSiteStartEndDateRet = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateIDDB(mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID);
                    Assert.AreEqual(mwqmSiteStartEndDateModelRet.MWQMSiteStartEndDateID, mwqmSiteStartEndDateRet.MWQMSiteStartEndDateID);

                    int MWQMSiteStartEndDateID = 0;
                    MWQMSiteStartEndDate mwqmSiteStartEndDateRet2 = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateIDDB(MWQMSiteStartEndDateID);
                    Assert.IsNull(mwqmSiteStartEndDateRet2);
                }
            }
        }
        public MWQMSiteStartEndDateModel AddMWQMSiteStartEndDateModel()
        {
            TVItemModel tvItemModelMWQMSite = randomService.RandomTVItem(TVTypeEnum.MWQMSite);

            Assert.IsNotNull(tvItemModelMWQMSite);

            mwqmSiteStartEndDateModelNew.MWQMSiteTVItemID = tvItemModelMWQMSite.TVItemID;
            FillMWQMSiteStartEndDateModel(mwqmSiteStartEndDateModelNew);

            MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = mwqmSiteStartEndDateService.PostAddMWQMSiteStartEndDateDB(mwqmSiteStartEndDateModelNew);

            if (!string.IsNullOrWhiteSpace(mwqmSiteStartEndDateModelRet.Error))
            {
                return(mwqmSiteStartEndDateModelRet);
            }

            CompareMWQMSiteStartEndDateModels(mwqmSiteStartEndDateModelNew, mwqmSiteStartEndDateModelRet);

            return(mwqmSiteStartEndDateModelRet);
        }
Example #25
0
        public MWQMSiteStartEndDateModel GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB(int MWQMSiteStartEndDateID)
        {
            MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel = (from c in db.MWQMSiteStartEndDates
                                                                   where c.MWQMSiteStartEndDateID == MWQMSiteStartEndDateID
                                                                   select new MWQMSiteStartEndDateModel
            {
                Error = "",
                MWQMSiteStartEndDateID = c.MWQMSiteStartEndDateID,
                DBCommand = (DBCommandEnum)c.DBCommand,
                MWQMSiteTVItemID = c.MWQMSiteTVItemID,
                StartDate = c.StartDate,
                EndDate = c.EndDate,
                LastUpdateDate_UTC = c.LastUpdateDate_UTC,
                LastUpdateContactTVItemID = c.LastUpdateContactTVItemID,
            }).FirstOrDefault <MWQMSiteStartEndDateModel>();

            if (mwqmSiteStartEndDateModel == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MWQMSiteStartEndDate, ServiceRes.MWQMSiteStartEndDateID, MWQMSiteStartEndDateID)));
            }

            return(mwqmSiteStartEndDateModel);
        }
        public void MWQMSiteStartEndDateService_PostAddMWQMSiteStartEndDateDB_Add_Error_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        //string ErrorText = "ErrorText";
                        shimMWQMSiteStartEndDateService.FillMWQMSiteStartEndDateMWQMSiteStartEndDateMWQMSiteStartEndDateModelContactOK = (a, b, c) =>
                        {
                            return("");
                        };

                        MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                        Assert.IsTrue(mwqmSiteStartEndDateModelRet.Error.StartsWith(string.Format(ServiceRes.CouldNotAddError_, "").Substring(0, 10)));
                    }
                }
            }
        }
        public void MWQMSiteStartEndDateService_PostAddMWQMSiteStartEndDateDB_FillMWQMSiteStartEndDateModel_ErrorTest()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    using (ShimsContext.Create())
                    {
                        SetupShim();
                        string ErrorText = "ErrorText";
                        shimMWQMSiteStartEndDateService.FillMWQMSiteStartEndDateMWQMSiteStartEndDateMWQMSiteStartEndDateModelContactOK = (a, b, c) =>
                        {
                            return(ErrorText);
                        };

                        MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = AddMWQMSiteStartEndDateModel();
                        Assert.AreEqual(ErrorText, mwqmSiteStartEndDateModelRet.Error);
                    }
                }
            }
        }
Example #28
0
        public MWQMSiteModel PostDeleteMWQMSiteDB(int MWQMSiteID)
        {
            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            MWQMSite mwqmSiteToDelete = GetMWQMSiteWithMWQMSiteIDDB(MWQMSiteID);

            if (mwqmSiteToDelete == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToDelete, ServiceRes.MWQMSite)));
            }

            int TVItemIDToDelete = mwqmSiteToDelete.MWQMSiteTVItemID;

            using (TransactionScope ts = new TransactionScope())
            {
                db.MWQMSites.Remove(mwqmSiteToDelete);
                string retStr = DoDeleteChanges();
                if (!string.IsNullOrWhiteSpace(retStr))
                {
                    return(ReturnError(retStr));
                }

                LogModel logModel = _LogService.PostAddLogForObj("MWQMSites", mwqmSiteToDelete.MWQMSiteID, LogCommandEnum.Delete, mwqmSiteToDelete);
                if (!string.IsNullOrWhiteSpace(logModel.Error))
                {
                    return(ReturnError(logModel.Error));
                }

                List <MWQMSiteStartEndDateModel> mwqmsiteStartEndDateModelList = _MWQMSiteStartEndDateService.GetMWQMSiteStartEndDateModelListWithMWQMSiteTVItemIDDB(mwqmSiteToDelete.MWQMSiteTVItemID);

                foreach (MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel in mwqmsiteStartEndDateModelList)
                {
                    MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = _MWQMSiteStartEndDateService.PostDeleteMWQMSiteStartEndDateDB(mwqmSiteStartEndDateModel.MWQMSiteStartEndDateID);
                    if (!string.IsNullOrWhiteSpace(mwqmSiteStartEndDateModelRet.Error))
                    {
                        return(ReturnError(mwqmSiteStartEndDateModelRet.Error));
                    }
                }

                List <MapInfoModel> mapInfoModelList = _MapInfoService.GetMapInfoModelListWithTVItemIDDB(mwqmSiteToDelete.MWQMSiteID);

                foreach (MapInfoModel mapInfoModel in mapInfoModelList)
                {
                    MapInfoModel mapInfoModelRet = _MapInfoService.PostDeleteMapInfoDB(mapInfoModel.MapInfoID);
                    if (!string.IsNullOrWhiteSpace(mapInfoModelRet.Error))
                    {
                        return(ReturnError(mapInfoModelRet.Error));
                    }
                }

                TVItemModel tvItemModelRet = _TVItemService.PostDeleteTVItemWithTVItemIDDB(TVItemIDToDelete);
                if (!string.IsNullOrWhiteSpace(tvItemModelRet.Error))
                {
                    return(ReturnError(tvItemModelRet.Error));
                }

                ts.Complete();
            }

            return(ReturnError(""));
        }
Example #29
0
        // Fill
        public string FillMWQMSiteStartEndDate(MWQMSiteStartEndDate mwqmSiteStartEndDate, MWQMSiteStartEndDateModel mwqmSiteStartEndDateModel, ContactOK contactOK)
        {
            mwqmSiteStartEndDate.DBCommand          = (int)mwqmSiteStartEndDateModel.DBCommand;
            mwqmSiteStartEndDate.MWQMSiteTVItemID   = mwqmSiteStartEndDateModel.MWQMSiteTVItemID;
            mwqmSiteStartEndDate.StartDate          = mwqmSiteStartEndDateModel.StartDate;
            mwqmSiteStartEndDate.EndDate            = mwqmSiteStartEndDateModel.EndDate;
            mwqmSiteStartEndDate.LastUpdateDate_UTC = DateTime.UtcNow;
            if (contactOK == null)
            {
                mwqmSiteStartEndDate.LastUpdateContactTVItemID = 2;
            }
            else
            {
                mwqmSiteStartEndDate.LastUpdateContactTVItemID = contactOK.ContactTVItemID;
            }

            return("");
        }
Example #30
0
        // Post
        public MWQMSiteStartEndDateModel MWQMSiteStartEndDateAddOrModifyDB(FormCollection fc)
        {
            int MWQMSiteStartEndDateID = 0;
            int MWQMSiteTVItemID       = 0;
            int StartDateYear          = 0;
            int StartDateMonth         = 0;
            int StartDateDay           = 0;
            int EndDateYear            = 0;
            int EndDateMonth           = 0;
            int EndDateDay             = 0;

            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrWhiteSpace(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            int.TryParse(fc["MWQMSiteStartEndDateID"], out MWQMSiteStartEndDateID);
            // could be 0 if 0 then we need to add the new MWQMSiteStartEndDate

            MWQMSiteStartEndDateModel mwqmSiteStartEndDateNewOrToChange = new MWQMSiteStartEndDateModel();

            if (MWQMSiteStartEndDateID > 0)
            {
                mwqmSiteStartEndDateNewOrToChange = GetMWQMSiteStartEndDateModelWithMWQMSiteStartEndDateIDDB(MWQMSiteStartEndDateID);
                if (!string.IsNullOrWhiteSpace(mwqmSiteStartEndDateNewOrToChange.Error))
                {
                    return(ReturnError(mwqmSiteStartEndDateNewOrToChange.Error));
                }
            }

            mwqmSiteStartEndDateNewOrToChange.DBCommand = DBCommandEnum.Original;

            int.TryParse(fc["MWQMSiteTVItemID"], out MWQMSiteTVItemID);
            if (MWQMSiteTVItemID == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.MWQMSiteTVItemID)));
            }

            mwqmSiteStartEndDateNewOrToChange.MWQMSiteTVItemID = MWQMSiteTVItemID;

            // Start Date
            int.TryParse(fc["StartDateYear"], out StartDateYear);
            if (StartDateYear == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.StartDateYear)));
            }

            int.TryParse(fc["StartDateMonth"], out StartDateMonth);
            if (StartDateMonth == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.StartDateMonth)));
            }

            int.TryParse(fc["StartDateDay"], out StartDateDay);
            if (StartDateDay == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.StartDateDay)));
            }

            mwqmSiteStartEndDateNewOrToChange.StartDate = new DateTime(StartDateYear, StartDateMonth, StartDateDay);

            // End Date
            int.TryParse(fc["EndDateYear"], out EndDateYear);
            if (EndDateYear == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.EndDateYear)));
            }

            int.TryParse(fc["EndDateMonth"], out EndDateMonth);
            if (EndDateMonth == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.EndDateMonth)));
            }

            int.TryParse(fc["EndDateDay"], out EndDateDay);
            if (EndDateDay == 0)
            {
                return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.EndDateDay)));
            }

            if (EndDateYear > 0)
            {
                mwqmSiteStartEndDateNewOrToChange.EndDate = new DateTime(EndDateYear, EndDateMonth, EndDateDay);
            }
            else
            {
                mwqmSiteStartEndDateNewOrToChange.EndDate = null;
            }

            MWQMSiteStartEndDateModel mwqmSiteStartEndDateModelRet = new MWQMSiteStartEndDateModel();

            using (TransactionScope ts = new TransactionScope())
            {
                if (MWQMSiteStartEndDateID == 0)
                {
                    mwqmSiteStartEndDateModelRet = PostAddMWQMSiteStartEndDateDB(mwqmSiteStartEndDateNewOrToChange);
                    if (!string.IsNullOrWhiteSpace(mwqmSiteStartEndDateModelRet.Error))
                    {
                        return(ReturnError(mwqmSiteStartEndDateModelRet.Error));
                    }
                }
                else
                {
                    mwqmSiteStartEndDateModelRet = PostUpdateMWQMSiteStartEndDateDB(mwqmSiteStartEndDateNewOrToChange);
                    if (!string.IsNullOrWhiteSpace(mwqmSiteStartEndDateModelRet.Error))
                    {
                        return(ReturnError(mwqmSiteStartEndDateModelRet.Error));
                    }
                }

                ts.Complete();
            }
            return(mwqmSiteStartEndDateModelRet);
        }