Beispiel #1
0
        internal List <SearchParam> GetSearchParameters()
        {
            List <SearchParam> parameters = new List <SearchParam>();

            // get search paramteres and their values
            if (_view.YearSearch != "")
            {
                parameters.Add(new SearchParamYear(Convert.ToInt32(_view.YearSearch)));
            }
            if (_view.MonthSearch != "")
            {
                parameters.Add(new SearchParamMonth(Convert.ToInt32(_view.MonthSearch)));
            }
            if (_view.LocationSearch != "")
            {
                parameters.Add(new SearchParamLocation(_view.LocationSearch));
            }
            if (_view.WindSearch != "")
            {
                parameters.Add(new SearchParamWind(CommonPresenterStuff.GetWindEnum(_view.WindSearch)));
            }
            if (_view.MoonPhaseSearch != "")
            {
                parameters.Add(new SearchParamMoonPhase(CommonPresenterStuff.GetMoonPhaseEnum(_view.MoonPhaseSearch)));
            }
            if (_view.TideSearch != "")
            {
                parameters.Add(new SearchParamTide(CommonPresenterStuff.GetTideEnum(_view.TideSearch)));
            }

            return(parameters);
        }
Beispiel #2
0
        public void FinishRequest()
        {
            FishingRecord record;

            // validate fields
            try
            {
                // date and time
                CommonPresenterStuff.ValidateDateEarlierThanNow(_view.DateTimeStart, "start date and time");
                CommonPresenterStuff.ValidateCronologicalDates(_view.DateTimeStart, _view.DateTimeEnd,
                                                               "start date and time", "end date and time");

                // location name
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.Location, "location");

                // nature events
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.Wind, "wind");
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.MoonPhase, "moon phase");
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.Tide, "tide");
            }
            catch (Exception e)
            {
                _view.ShowErrorMessage(e.Message);
                return;
            }

            // if fish catch or sale is empty, warn user
            if (_fishCatch.GetCaughtFish().Count == 0)
            {
                if (!_view.WarnUser(CommonPresenterStuff.WarnFieldEmptyMessage("fish catch")))
                {
                    return;
                }
            }
            if (_fishCatch.GetSoldFish().Count == 0)
            {
                if (!_view.WarnUser(CommonPresenterStuff.WarnFieldEmptyMessage("fish sale")))
                {
                    return;
                }
            }

            // try create record
            Winds      wind      = CommonPresenterStuff.GetWindEnum(_view.Wind);
            MoonPhases moonPhase = CommonPresenterStuff.GetMoonPhaseEnum(_view.MoonPhase);
            Tides      tide      = CommonPresenterStuff.GetTideEnum(_view.Tide);

            try
            {
                record = FishingRecordFactory.CreateFishingRecord(_view.DateTimeStart, _view.DateTimeEnd,
                                                                  _view.Location, wind, moonPhase, tide, _fishCatch);
            }
            catch (Exception)
            {
                _view.ShowErrorMessage(CommonPresenterStuff.ErrorMessage());
                return;
            }

            Finish(record);
        }