public AsyncOperationState <IList <Place>, Criteria> Reduce(AsyncOperationState <IList <Place>, Criteria> previousState, IAction action) { if (action is GetPlacesStartAction <Criteria> ) { var downloadPlacesListByCriteriaStartAction = action as GetPlacesStartAction <Criteria>; return(previousState .Set(v => v.TriggerValue, downloadPlacesListByCriteriaStartAction.Value) .Set(v => v.Status, downloadPlacesListByCriteriaStartAction.Status) .Build()); } if (action is GetPlacesListByCriteriaCompleteAction) { var downloadPlacesListByCriteriaCompleteAction = action as GetPlacesListByCriteriaCompleteAction; return(previousState .Set(v => v.Value, downloadPlacesListByCriteriaCompleteAction.PlacesList) .Set(v => v.Status, downloadPlacesListByCriteriaCompleteAction.Status) .Set(v => v.Error, downloadPlacesListByCriteriaCompleteAction.Error) .Build()); } return(previousState); }
public AsyncOperationState <IList <Place>, long> Reduce(AsyncOperationState <IList <Place>, long> previousState, IAction action) { if (action is GetPlacesStartAction <long> ) { var getPlacesListByUserIdAction = action as GetPlacesStartAction <long>; return(previousState .Set(v => v.TriggerValue, getPlacesListByUserIdAction.Value) .Set(v => v.Status, getPlacesListByUserIdAction.Status) .Build()); } if (action is GetPlacesListByUserIdCompleteAction) { var getPlacesListByUserIdCompleteAction = action as GetPlacesListByUserIdCompleteAction; return(previousState .Set(v => v.Value, getPlacesListByUserIdCompleteAction.PlacesList) .Set(v => v.Status, getPlacesListByUserIdCompleteAction.Status) .Set(v => v.Error, getPlacesListByUserIdCompleteAction.Error) .Build()); } return(previousState); }
public AsyncOperationState <User, Unit> Reduce(AsyncOperationState <User, Unit> previousState, IAction action) { if (action is SetRegisterUserStartAction) { var setRegisterUserStartAction = action as SetRegisterUserStartAction; return(previousState .Set(v => v.Error, setRegisterUserStartAction.Error) .Set(v => v.Status, setRegisterUserStartAction.Status) .Set(v => v.Value, setRegisterUserStartAction.User) .Build()); } if (action is SetRegisterUserCompleteAction) { var setRegisterCompleteAction = action as SetRegisterUserCompleteAction; return(previousState .Set(v => v.Error, setRegisterCompleteAction.Error) .Set(v => v.Status, setRegisterCompleteAction.Status) .Set(v => v.Value, setRegisterCompleteAction.User) .Build()); } return(previousState); }
public AsyncOperationState <Place, int> Reduce(AsyncOperationState <Place, int> previousState, IAction action) { if (action is GetPlaceByIdStartAction) { var downloadPlaceByIdStartAction = action as GetPlaceByIdStartAction; return(previousState .Set(v => v.TriggerValue, downloadPlaceByIdStartAction.Id) .Set(v => v.Status, Status.Getting) .Build()); } if (action is GetPlaceByIdCompleteAction) { var downloadPlaceByIdCompleteAction = action as GetPlaceByIdCompleteAction; return(previousState .Set(v => v.Value, downloadPlaceByIdCompleteAction.Place) .Set(v => v.Status, downloadPlaceByIdCompleteAction.Status) .Set(v => v.Error, downloadPlaceByIdCompleteAction.Error) .Build()); } return(previousState); }
public AsyncOperationState <User, AccessProvider> Reduce(AsyncOperationState <User, AccessProvider> previousState, IAction action) { if (action is SetLoginStartAction) { var setLoginStartAction = action as SetLoginStartAction; return(previousState .Set(v => v.Value, setLoginStartAction.User) .Set(v => v.Status, setLoginStartAction.Status) .Set(v => v.Error, setLoginStartAction.Error) .Build()); } if (action is SetLoginCompleteAction) { var setLoginCompleteAction = action as SetLoginCompleteAction; return(previousState .Set(v => v.Error, setLoginCompleteAction.Error) .Set(v => v.Status, setLoginCompleteAction.Status) .Set(v => v.Value, setLoginCompleteAction.User) .Build()); } return(previousState); }
public AsyncOperationState <WrongPlaceReport, Unit> Reduce(AsyncOperationState <WrongPlaceReport, Unit> previousState, IAction action) { if (action is SetWrongPlaceReportStartAction) { var setWrongPlaceReportStartAction = action as SetWrongPlaceReportStartAction; return(previousState .Set(v => v.Status, setWrongPlaceReportStartAction.Status) .Set(v => v.Value, setWrongPlaceReportStartAction.WrongPlaceReport) .Set(v => v.Error, null) .Build()); } if (action is SetWrongPlaceReportCompleteAction) { var setWrongPlaceReportCompleteAction = action as SetWrongPlaceReportCompleteAction; return(previousState .Set(v => v.Status, setWrongPlaceReportCompleteAction.Status) .Set(v => v.Value, setWrongPlaceReportCompleteAction.WrongPlaceReport) .Set(v => v.Error, setWrongPlaceReportCompleteAction.Error) .Build()); } if (action is SetEmptyWrongPlaceReportAction) { return(previousState .Set(v => v.Status, Core.Enums.Status.Empty) .Set(v => v.Value, null) .Set(v => v.Error, null) .Build()); } return(previousState); }
public AsyncOperationState <Report, Unit> Reduce(AsyncOperationState <Report, Unit> previousState, IAction action) { if (action is SetNewReportAction) { return(previousState .Set(v => v.Value, new Report(null, null, Core.Enums.ReportType.Create)) .Build()); } if (action is SetUpdateReportPlaceAction) { var setUpdateReportPlaceAction = action as SetUpdateReportPlaceAction; return(previousState .Set(v => v.Value, new Report(setUpdateReportPlaceAction.Place, setUpdateReportPlaceAction.Place.Location, Core.Enums.ReportType.Update)) .Build()); } if (action is SetReportPlaceAction) { var passPlaceToReportAction = action as SetReportPlaceAction; var newReportObject = previousState.Value .Set(v => v.Place, passPlaceToReportAction.Place) .Build(); return(previousState .Set(v => v.Value, newReportObject) .Build()); } if (action is SetReportUserAction) { var setReportUserAction = action as SetReportUserAction; var updatedPlace = previousState.Value.Place; updatedPlace.UserId = setReportUserAction.User.Id; var newReportObject = previousState.Value .Set(v => v.Place, updatedPlace) .Build(); return(previousState .Set(v => v.Value, newReportObject) .Build()); } if (action is SetReportLocationAction) { //TODO: Place HAVE TO be immutable. var updateLocationInReportAction = action as SetReportLocationAction; previousState.Value.Place.Location = updateLocationInReportAction.Location; var newReportObject = previousState.Value .Set(v => v.Location, updateLocationInReportAction.Location) .Build(); return(previousState .Set(v => v.Value, newReportObject) .Build()); } return(previousState); }