public override void Finish(FishingRecord record) { // try adding record try { FishingRecordRepository.GetInstance().AddRecord(record); } catch (FishingRecordAlreadyExistsException) { _view.ShowErrorMessage("Fishing record already exists!"); return; } catch (FishingRecordsInCollisionException) { _view.ShowErrorMessage(_fishingRecordsInCollisionError); return; } catch (Exception) { _view.ShowErrorMessage(CommonPresenterStuff.ErrorMessage()); return; } NotifyObservers(new Object()); _view.ShowMessage("Fishing record added."); _view.End(); }
public PresenterFishingRecordEdit(IViewFishingRecord inView, int inRecordIndex) : base(inView) { _recordIndex = inRecordIndex; FishingRecord record = FishingRecordRepository.GetInstance().GetRecord(inRecordIndex); _fishCatch = record.FishCatch; // set record details on view _view.DateTimeStart = record.DateTimeInterval.Start; _view.DateTimeEnd = record.DateTimeInterval.End; _view.Location = record.Location.Name; _view.Wind = CommonPresenterStuff.GetWindStrings()[(int)record.NatureContex.Wind]; _view.MoonPhase = CommonPresenterStuff.GetMoonPhaseStrings()[(int)record.NatureContex.MoonPhase]; _view.Tide = CommonPresenterStuff.GetTideStrings()[(int)record.NatureContex.Tide]; foreach (string fish in record.FishCatch.GetCaughtFish()) { _view.AddFishCatch(fish, record.FishCatch.GetCaughtFishMass(fish)); } foreach (string fish in record.FishCatch.GetSoldFish()) { _view.AddFishSale(fish, record.FishCatch.GetSoldFishMass(fish), record.FishCatch.GetSoldFishPrice(fish)); } _view.SetFinishButtonText("Save changes"); }
public void Test_AddSameFishingRecordTwice() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.AddRecord(record1); repository.AddRecord(record1); }
public void Test_AddFishingRecordInCollision2() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.AddRecord(record1); record2.DateTimeInterval = new DateTimeInterval(new DateTime(2013, 9, 1, 11, 00, 00), new DateTime(2013, 9, 1, 17, 00, 00)); repository.AddRecord(record2); }
public void Test_AddFishingRecord() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.AddRecord(record1); Assert.AreEqual(1, repository.Count()); }
public void SearchRequest() { List <SearchParam> parameters = GetSearchParameters(); List <FishingRecord> matches = Search.Find(FishingRecordRepository.GetInstance().GetRecords(), parameters); ShowRecords(matches); }
public void Test_GetFishingRecord() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.AddRecord(record1); FishingRecord recordGet = repository.GetRecord(0); Assert.AreEqual(record1, recordGet); }
public void DeleteRecordRequest(int inRecordIndex) { // warn user if (_view.WarnUser(CommonPresenterStuff.WarnDeleteMessage("fishing record"))) { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.DeleteRecord(inRecordIndex); } }
public void Test_UpdateFishingRecord() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.AddRecord(record1); repository.UpdateRecord(0, record2); FishingRecord recordGet = repository.GetRecord(0); Assert.AreEqual(record1, recordGet); string expectedLocation = "Medulin"; string resultLocation = recordGet.Location.Name; Assert.AreEqual(expectedLocation, resultLocation); }
public void Test_DeleteLocationThanIsPartOfAFishingRecord() { LocationRepository locRepository = LocationRepository.GetInstance(); locRepository.AddLocation(location1); FishingRecordRepository recRepository = FishingRecordRepository.GetInstance(); recRepository.DeleteAllRecords(); FishingRecord record = EntityGenerator.GetFishingRecord1(); record.Location = location1; recRepository.AddRecord(record); locRepository.DeleteLocation(0); }
public PresenterMain(IViewMain inView) { _view = inView; // load records FishingRecordRepository repository = FishingRecordRepository.GetInstance(); ShowRecords(repository.GetRecords()); // init search fields SetPossibleSearchValues(); // attach self to repositories repository.Attach(this); LocationRepository.GetInstance().Attach(this); }
public PresenterStatistics(IViewStatistics inView, PresenterMain inParentPresenter) { _view = inView; // show number of records found/total number of records List <SearchParam> searchParams = inParentPresenter.GetSearchParameters(); FishingRecordRepository repository = FishingRecordRepository.GetInstance(); _recordsFound = Search.Find(repository.GetRecords(), searchParams); _view.ShowNumberOfRecordsFound(_recordsFound.Count, repository.Count()); // show available reports List <string> availableReports = new List <string>(); availableReports.Add("Fish catch"); availableReports.Add("Fish profit"); _view.AvailableReports = availableReports.ToArray(); }
public StatisticsPresenter(IStatisticsView inView, PresenterMain inParentPresenter) { _view = inView; _parent = inParentPresenter; // show number of records found/total number of records List <SearchParameter> searchParams = _parent.GetSearchParameters(); FishingRecordRepository repository = FishingRecordRepository.GetInstance(); _recordsFound = SearchService.Find(repository.GetRecords(), searchParams); _view.ShowNumberOfRecordsFound(_recordsFound.Count, repository.Count()); // show available reports _availableReportsDict = new Dictionary <string, Reporter>(); _availableReportsDict.Add("Fish catch", new FishCatchReporter()); _availableReportsDict.Add("Fish profit", new FishSaleReporter()); _view.AvailableReports = _availableReportsDict.Keys.ToArray(); }
public void AddFishingRecordRequest() { // ensure nature contex is not empty if (_view.Wind == "") { _view.ShowErrorMessage(_windEmptyError); return; } if (_view.MoonPhase == "") { _view.ShowErrorMessage(_moonPhaseEmptyError); return; } if (_view.Tide == "") { _view.ShowErrorMessage(_tideEmptyError); return; } Winds wind = CommonFunctionalities.GetWindEnum(_view.Wind); MoonPhases moonPhase = CommonFunctionalities.GetMoonPhaseEnum(_view.MoonPhase); Tides tide = CommonFunctionalities.GetTideEnum(_view.Tide); try { FishingRecord record = FishingRecordFactory.CreateFishingRecord(_view.StartDateTime, _view.EndDateTime, _view.Location, wind, moonPhase, tide, fishCatch); FishingRecordRepository.GetInstance().AddRecord(record); } catch (FishermanBaseException e) { _view.ShowErrorMessage(e.Info); return; } _parent.AddRecordName(DateTime.Now); _view.End(); }
public override void Finish(FishingRecord record) { // try updating records try { FishingRecordRepository.GetInstance().UpdateRecord(_recordIndex, record); } catch (FishingRecordsInCollisionException) { _view.ShowErrorMessage(_fishingRecordsInCollisionError); return; } catch (Exception) { _view.ShowErrorMessage(CommonPresenterStuff.ErrorMessage()); } NotifyObservers(new Object()); _view.ShowMessage("Changes saved."); _view.End(); }
public void Update(object inObject) { ShowRecords(FishingRecordRepository.GetInstance().GetRecords()); SetPossibleSearchValues(); }
public void ShowAllRecordsRequest() { ShowRecords(FishingRecordRepository.GetInstance().GetRecords()); }
public void Test_UpdateFishingRecordThanDoesntExist() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.UpdateRecord(0, record1); }
public void Test_DeleteFishingRecordThanDoesntExist() { FishingRecordRepository repository = FishingRecordRepository.GetInstance(); repository.DeleteRecord(0); }
public void ReInitializeFishingRecordRepository() { FishingRecordRepository.GetInstance().DeleteAllRecords(); }