Merged building faas and land faas

dev
cyzoox 2023-09-01 11:22:48 +08:00
commit eaabcda3d7
281 changed files with 27965 additions and 2944 deletions

View File

@ -0,0 +1,21 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/barangay.dart';
import 'package:unit2/sevices/passo/barangay.dart';
part 'barangay_event.dart';
part 'barangay_state.dart';
class BarangayBloc extends Bloc<BarangayEvent, BarangayState> {
BarangayBloc() : super(BarangayInitial()) {
on<LoadBarangay>((event, emit) async {
emit(BarangayLoading());
try {
final barangay = await BarangayServices.instance.fetch(event.id);
emit(BarangayLoaded(barangay));
} catch (e) {
emit(BarangayErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,17 @@
part of 'barangay_bloc.dart';
abstract class BarangayEvent extends Equatable {
const BarangayEvent();
@override
List<Object> get props => [];
}
class LoadBarangay extends BarangayEvent {
final String id;
const LoadBarangay({required this.id});
@override
List<Object> get props => [id];
}

View File

@ -0,0 +1,28 @@
part of 'barangay_bloc.dart';
abstract class BarangayState extends Equatable {
const BarangayState();
@override
List<Object> get props => [];
}
class BarangayInitial extends BarangayState {}
class BarangayLoading extends BarangayState {}
class BarangayLoaded extends BarangayState {
BarangayLoaded(this.brgy);
final List<Brgy> brgy;
@override
List<Object> get props => [brgy];
}
class BarangayErrorState extends BarangayState {
BarangayErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -27,8 +27,8 @@ class AdditionalItemBloc
}
});
on<AddAdditionalItems>((event, emit) async {
http.Response response = (await AdditionalItemsServices.instance
.postAdditionalItems(event.items))!;
http.Response response =
(await AdditionalItemsServices.instance.add(event.items))!;
print(response.body);
if (response.statusCode == 201) {
@ -43,8 +43,8 @@ class AdditionalItemBloc
});
on<DeleteAdditionalItems>((event, emit) async {
print(event.id);
http.Response response = (await AdditionalItemsServices.instance
.removeAdditionalItems(event.id));
http.Response response =
(await AdditionalItemsServices.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
globalAdditionalItems

View File

@ -0,0 +1,63 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/additional_items.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/building/additional_items_services.dart';
part 'additional_items_edit_event.dart';
part 'additional_items_edit_state.dart';
class AdditionalItemsEditBloc
extends Bloc<AdditionalItemsEditEvent, AdditionalItemsEditState> {
AdditionalItemsEditBloc() : super(AdditionalItemsEditInitial()) {
List<AdditionalItems> globalAdditionalItemsEdit = [];
on<LoadAdditionalItemsEdit>((event, emit) async {
if (globalAdditionalItemsEdit.isEmpty) {
emit(AdditionalItemsEditLoading());
try {
final additionalItems =
await AdditionalItemsServices.instance.fetch(event.id);
globalAdditionalItemsEdit
.addAll(additionalItems); // Append fetched data
emit(AdditionalItemsEditLoaded(globalAdditionalItemsEdit));
} catch (e) {
emit(AdditionalItemsEditErrorState(e.toString()));
}
} else {
emit(AdditionalItemsEditLoaded(globalAdditionalItemsEdit));
}
});
on<AddAdditionalItemsEdit>((event, emit) async {
http.Response response =
(await AdditionalItemsServices.instance.add(event.items))!;
print(response.statusCode);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
AdditionalItems newAdditional =
AdditionalItems.fromJson(jsonResponse['data']);
print(jsonResponse['data']);
globalAdditionalItemsEdit.add(newAdditional);
emit(AdditionalItemsEditLoaded(globalAdditionalItemsEdit));
}
});
on<ShowAdditionalItemsEdit>((event, emit) async {
emit(ShowAddItemsScreenEdit());
});
on<DeleteAdditionalItemsEdit>((event, emit) async {
print(event.id);
http.Response response =
(await AdditionalItemsServices.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
globalAdditionalItemsEdit
.removeWhere(((AdditionalItems element) => element.id == event.id));
emit(AdditionalItemsEditDeletedState(success: true));
}
});
}
}

View File

@ -0,0 +1,38 @@
part of 'additional_items_edit_bloc.dart';
abstract class AdditionalItemsEditEvent extends Equatable {
const AdditionalItemsEditEvent();
@override
List<Object> get props => [];
}
class LoadAdditionalItemsEdit extends AdditionalItemsEditEvent {
final List<AdditionalItems> items;
final int? id;
const LoadAdditionalItemsEdit({required this.items, this.id});
@override
List<Object> get props => [items];
}
class AddAdditionalItemsEdit extends AdditionalItemsEditEvent {
final AdditionalItems items;
const AddAdditionalItemsEdit({required this.items});
@override
List<Object> get props => [items];
}
class ShowAdditionalItemsEdit extends AdditionalItemsEditEvent {}
class DeleteAdditionalItemsEdit extends AdditionalItemsEditEvent {
final int id;
const DeleteAdditionalItemsEdit({required this.id});
@override
List<Object> get props => [id];
}

View File

@ -0,0 +1,37 @@
part of 'additional_items_edit_bloc.dart';
abstract class AdditionalItemsEditState extends Equatable {
const AdditionalItemsEditState();
@override
List<Object> get props => [];
}
class AdditionalItemsEditInitial extends AdditionalItemsEditState {}
class AdditionalItemsEditLoading extends AdditionalItemsEditState {}
class AdditionalItemsEditLoaded extends AdditionalItemsEditState {
const AdditionalItemsEditLoaded(this.items);
final List<AdditionalItems> items;
@override
List<Object> get props => [items];
}
class AdditionalItemsEditErrorState extends AdditionalItemsEditState {
const AdditionalItemsEditErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}
class ShowAddItemsScreenEdit extends AdditionalItemsEditState {}
class AdditionalItemsEditDeletedState extends AdditionalItemsEditState {
final bool success;
const AdditionalItemsEditDeletedState({required this.success});
@override
List<Object> get props => [success];
}

View File

@ -12,7 +12,7 @@ class ClassComponentsBloc
on<LoadClassComponents>((event, emit) async {
emit(ClassComponentLoading());
try {
final classs = await ClassComponentService.instance.getClassComponent();
final classs = await ClassComponentService.instance.fetch();
emit(ClassComponentLoaded(classs));
} catch (e) {
emit(ClassComponentErrorState(e.toString()));

View File

@ -0,0 +1,23 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/general_description.dart';
import 'package:unit2/sevices/passo/building/general_description_services.dart';
part 'general_description_event.dart';
part 'general_description_state.dart';
class GeneralDescriptionBloc
extends Bloc<GeneralDescriptionEvent, GeneralDescriptionState> {
GeneralDescriptionBloc() : super(GenDescLoading()) {
on<LoadGenDesc>((event, emit) async {
emit(GenDescLoading());
try {
final gendesc =
await GeneralDescriptionServices.instance.fetch(event.id);
emit(GenDescLoaded(gendesc));
} catch (e) {
emit(GenDescErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,27 @@
part of 'general_description_bloc.dart';
abstract class GeneralDescriptionEvent extends Equatable {
const GeneralDescriptionEvent();
@override
List<Object> get props => [];
}
class LoadGenDesc extends GeneralDescriptionEvent {
final GeneralDesc gendesc;
final int? id;
const LoadGenDesc({required this.gendesc, required this.id});
@override
List<Object> get props => [gendesc];
}
class UpdateGenDesc extends GeneralDescriptionEvent {
final GeneralDesc gendesc;
const UpdateGenDesc(this.gendesc);
@override
List<Object> get props => [gendesc];
}

View File

@ -0,0 +1,26 @@
part of 'general_description_bloc.dart';
abstract class GeneralDescriptionState extends Equatable {
const GeneralDescriptionState();
@override
List<Object> get props => [];
}
class GenDescLoading extends GeneralDescriptionState {}
class GenDescLoaded extends GeneralDescriptionState {
GenDescLoaded(this.gendesc);
final GeneralDesc gendesc;
@override
List<Object> get props => [gendesc];
}
class GenDescErrorState extends GeneralDescriptionState {
GenDescErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,21 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/land_ref.dart';
import 'package:unit2/sevices/passo/building/landref_services.dart';
part 'landref_event.dart';
part 'landref_state.dart';
class LandrefBloc extends Bloc<LandrefEvent, LandrefState> {
LandrefBloc() : super(LandrefLoading()) {
on<LoadLandref>((event, emit) async {
emit(LandrefLoading());
try {
final landRef = await LandRefServices.instance.fetch(event.id);
emit(LandrefLoaded(landRef));
} catch (e) {
emit(LandrefErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,27 @@
part of 'landref_bloc.dart';
abstract class LandrefEvent extends Equatable {
const LandrefEvent();
@override
List<Object> get props => [];
}
class LoadLandref extends LandrefEvent {
final LandRef landRef;
final int? id;
const LoadLandref({required this.landRef, required this.id});
@override
List<Object> get props => [landRef];
}
class UpdateLandref extends LandrefEvent {
final LandRef landRef;
const UpdateLandref(this.landRef);
@override
List<Object> get props => [landRef];
}

View File

@ -0,0 +1,26 @@
part of 'landref_bloc.dart';
abstract class LandrefState extends Equatable {
const LandrefState();
@override
List<Object> get props => [];
}
class LandrefLoading extends LandrefState {}
class LandrefLoaded extends LandrefState {
LandrefLoaded(this.landRef);
final LandRef landRef;
@override
List<Object> get props => [landRef];
}
class LandrefErrorState extends LandrefState {
LandrefErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,21 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/bldg_loc.dart';
import 'package:unit2/sevices/passo/building/location_landref_services.dart';
part 'location_event.dart';
part 'location_state.dart';
class LocationBloc extends Bloc<LocationEvent, LocationState> {
LocationBloc() : super(LocationLoading()) {
on<LoadLocation>((event, emit) async {
emit(LocationLoading());
try {
final bldgloc = await LocationLandrefServices.instance.fetch(event.id);
emit(LocationLoaded(bldgloc));
} catch (e) {
emit(LocationErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,27 @@
part of 'location_bloc.dart';
abstract class LocationEvent extends Equatable {
const LocationEvent();
@override
List<Object> get props => [];
}
class LoadLocation extends LocationEvent {
final BldgLoc bldgloc;
final int? id;
const LoadLocation({required this.bldgloc, required this.id});
@override
List<Object> get props => [bldgloc];
}
class UpdateLocation extends LocationEvent {
final BldgLoc bldgloc;
const UpdateLocation(this.bldgloc);
@override
List<Object> get props => [bldgloc];
}

View File

@ -0,0 +1,26 @@
part of 'location_bloc.dart';
abstract class LocationState extends Equatable {
const LocationState();
@override
List<Object> get props => [];
}
class LocationLoading extends LocationState {}
class LocationLoaded extends LocationState {
LocationLoaded(this.bldgloc);
final BldgLoc bldgloc;
@override
List<Object> get props => [bldgloc];
}
class LocationErrorState extends LocationState {
LocationErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -17,10 +17,7 @@ class PropertyAppraisalBloc
on<LoadPropertyAppraisal>((event, emit) async {
emit(PropertyAppraisalLoading());
try {
final tempID = await SharedPreferences.getInstance();
final appraisal = await PropertyAppraisalServices.instance
.getPropertyAppraisal(tempID.getInt('tempid'));
final appraisal = await PropertyAppraisalServices.instance.fetch();
emit(PropertyAppraisalLoaded(appraisal));
} catch (e) {
@ -28,17 +25,20 @@ class PropertyAppraisalBloc
}
});
on<AddPropertyAppraisal>((event, emit) async {
final tempID = await SharedPreferences.getInstance();
http.Response response = (await PropertyAppraisalServices.instance
.postPropertyAppraisal(event.appraisal))!;
.update(event.appraisal, tempID.getInt('tempid')! - 1))!;
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
PropertyAppraisal newAppraisal =
PropertyAppraisal.fromJson(jsonResponse['data']);
print(jsonResponse['data']);
globalPropertyAppraisal.add(newAppraisal);
print("PA");
print(newAppraisal);
print(response.statusCode);
emit(PropertyAppraisalLoaded(globalPropertyAppraisal));
emit(PropertyAppraisalLoaded(newAppraisal));
}
});
}

View File

@ -8,9 +8,9 @@ abstract class PropertyAppraisalEvent extends Equatable {
}
class LoadPropertyAppraisal extends PropertyAppraisalEvent {
final List<PropertyAppraisal> appraisal;
final PropertyAppraisal appraisal;
const LoadPropertyAppraisal({this.appraisal = const <PropertyAppraisal>[]});
const LoadPropertyAppraisal({required this.appraisal});
@override
List<Object> get props => [appraisal];

View File

@ -13,7 +13,7 @@ class PropertyAppraisalLoading extends PropertyAppraisalState {}
class PropertyAppraisalLoaded extends PropertyAppraisalState {
PropertyAppraisalLoaded(this.appraisal);
final List<PropertyAppraisal> appraisal;
final PropertyAppraisal appraisal;
@override
List<Object> get props => [appraisal];

View File

@ -0,0 +1,40 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/property_appraisal_edit.dart';
import 'package:unit2/sevices/passo/building/property_appraisal_services.dart';
import 'package:http/http.dart' as http;
part 'property_appraisal_edit_event.dart';
part 'property_appraisal_edit_state.dart';
class PropertyAppraisalEditBloc
extends Bloc<PropertyAppraisalEditEvent, PropertyAppraisalEditState> {
PropertyAppraisalEditBloc() : super(PropertyAppraisalEditLoading()) {
on<LoadPropertyAppraisalEdit>((event, emit) async {
emit(PropertyAppraisalEditLoading());
try {
final appraisalEdit =
await PropertyAppraisalServices.instance.fetchEdit(event.id);
emit(PropertyAppraisalEditLoaded(appraisalEdit));
} catch (e) {
emit(PropertyAppraisalEditErrorState(e.toString()));
}
});
on<UpdatePropertyAppraisalEdit>((event, emit) async {
http.Response response = (await PropertyAppraisalServices.instance
.updateAppraisal(event.appraisalEdit!, event.id))!;
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
PropertyAppraisalEdit newAppraisal =
PropertyAppraisalEdit.fromJson(jsonResponse['data']);
print(response.statusCode);
emit(PropertyAppraisalEditLoaded(newAppraisal));
// emit(PropertyAppraisalLoaded(globalPropertyAppraisal));
}
});
}
}

View File

@ -0,0 +1,28 @@
part of 'property_appraisal_edit_bloc.dart';
abstract class PropertyAppraisalEditEvent extends Equatable {
const PropertyAppraisalEditEvent();
@override
List<Object> get props => [];
}
class LoadPropertyAppraisalEdit extends PropertyAppraisalEditEvent {
final PropertyAppraisalEdit appraisalEdit;
final int? id;
const LoadPropertyAppraisalEdit(
{required this.appraisalEdit, required this.id});
@override
List<Object> get props => [appraisalEdit];
}
class UpdatePropertyAppraisalEdit extends PropertyAppraisalEditEvent {
final PropertyAppraisalEdit? appraisalEdit;
final int? id;
const UpdatePropertyAppraisalEdit({this.appraisalEdit, required this.id});
@override
List<Object> get props => [appraisalEdit!];
}

View File

@ -0,0 +1,26 @@
part of 'property_appraisal_edit_bloc.dart';
abstract class PropertyAppraisalEditState extends Equatable {
const PropertyAppraisalEditState();
@override
List<Object> get props => [];
}
class PropertyAppraisalEditLoading extends PropertyAppraisalEditState {}
class PropertyAppraisalEditLoaded extends PropertyAppraisalEditState {
PropertyAppraisalEditLoaded(this.appraisalEdit);
final PropertyAppraisalEdit appraisalEdit;
@override
List<Object> get props => [appraisalEdit];
}
class PropertyAppraisalEditErrorState extends PropertyAppraisalEditState {
PropertyAppraisalEditErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -20,7 +20,7 @@ class PropertyAssessmentBloc
final tempID = await SharedPreferences.getInstance();
final assessments = await PropertyAssessmentServices.instance
.getPropertyAssessment(tempID.getInt('tempid')! + 1);
.fetch(tempID.getInt('tempid')! + 1);
emit(PropertyAssessmentLoaded(assessments));
} catch (e) {
@ -28,8 +28,8 @@ class PropertyAssessmentBloc
}
});
on<AddPropertyAssessment>((event, emit) async {
http.Response response = (await PropertyAssessmentServices.instance
.postPropertyAssessment(event.assessments))!;
http.Response response =
(await PropertyAssessmentServices.instance.add(event.assessments))!;
print('Assessment');
print(response.statusCode);
print(response.body);
@ -47,7 +47,7 @@ class PropertyAssessmentBloc
final tempID = await SharedPreferences.getInstance();
final tempID2 = tempID.getInt('tempid')! - 1;
http.Response response = (await PropertyAssessmentServices.instance
.propertyAssessmentPutInfo(event.assessment, tempID2))!;
.update(event.assessment, tempID2))!;
print('assessment');
print(response.statusCode);
print(response.body);

View File

@ -0,0 +1,61 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/property_assessment_edit.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/building/property_assessment_services.dart';
part 'property_assessment_edit_event.dart';
part 'property_assessment_edit_state.dart';
class PropertyAssessmentEditBloc
extends Bloc<PropertyAssessmentEditEvent, PropertyAssessmentEditState> {
PropertyAssessmentEdit globalPropertyAssessmentEdit;
PropertyAssessmentEditBloc()
: globalPropertyAssessmentEdit = PropertyAssessmentEdit(),
super(PropertyAssessmentEditInitial()) {
on<LoadPropertyAssessmentEdit>((event, emit) async {
emit(PropertyAssessmentEditLoading());
try {
final tempID = await SharedPreferences.getInstance();
final assessments =
await PropertyAssessmentServices.instance.fetchEdit(event.id);
emit(PropertyAssessmentEditLoaded(assessments));
} catch (e) {
emit(PropertyAssessmentEditErrorState(e.toString()));
}
});
on<AddPropertyAssessmentEdit>((event, emit) async {
http.Response response = (await PropertyAssessmentServices.instance
.addEdit(event.assessmentsEdit))!;
print('Assessment');
print(response.statusCode);
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
PropertyAssessmentEdit newAssessment =
PropertyAssessmentEdit.fromJson(jsonResponse['data']);
globalPropertyAssessmentEdit = newAssessment;
emit(PropertyAssessmentEditLoaded(globalPropertyAssessmentEdit));
}
});
on<UpdatePropertyAssessmentEdit>((event, emit) async {
final tempID = await SharedPreferences.getInstance();
final tempID2 = tempID.getInt('tempid')! - 1;
http.Response response = (await PropertyAssessmentServices.instance
.updateEdit(event.assessmentsEdit, tempID2))!;
print('assessment');
print(response.statusCode);
print(response.body);
// if (response.statusCode == 201) {
// final faas = await PropertyInfoRepository.getUsers();
// emit(FaasLoaded(faas));
// }
});
}
}

View File

@ -0,0 +1,39 @@
part of 'property_assessment_edit_bloc.dart';
abstract class PropertyAssessmentEditEvent extends Equatable {
const PropertyAssessmentEditEvent();
@override
List<Object> get props => [];
}
class LoadPropertyAssessmentEdit extends PropertyAssessmentEditEvent {
final PropertyAssessmentEdit assessmentsEdit;
final int? id;
const LoadPropertyAssessmentEdit(
{required this.assessmentsEdit, required this.id});
@override
List<Object> get props => [assessmentsEdit];
}
class AddPropertyAssessmentEdit extends PropertyAssessmentEditEvent {
final PropertyAssessmentEdit assessmentsEdit;
const AddPropertyAssessmentEdit({required this.assessmentsEdit});
@override
List<Object> get props => [assessmentsEdit];
}
class UpdatePropertyAssessmentEdit extends PropertyAssessmentEditEvent {
// ignore: non_constant_identifier_names
final PropertyAssessmentEdit assessmentsEdit;
// ignore: non_constant_identifier_names
const UpdatePropertyAssessmentEdit({required this.assessmentsEdit});
@override
List<Object> get props => [assessmentsEdit];
}

View File

@ -0,0 +1,28 @@
part of 'property_assessment_edit_bloc.dart';
abstract class PropertyAssessmentEditState extends Equatable {
const PropertyAssessmentEditState();
@override
List<Object> get props => [];
}
class PropertyAssessmentEditInitial extends PropertyAssessmentEditState {}
class PropertyAssessmentEditLoading extends PropertyAssessmentEditState {}
class PropertyAssessmentEditLoaded extends PropertyAssessmentEditState {
PropertyAssessmentEditLoaded(this.assessmentsEdit);
final PropertyAssessmentEdit assessmentsEdit;
@override
List<Object> get props => [assessmentsEdit];
}
class PropertyAssessmentEditErrorState extends PropertyAssessmentEditState {
PropertyAssessmentEditErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,112 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/bldg_loc.dart';
import 'package:unit2/model/passo/general_description.dart';
import 'package:unit2/model/passo/land_ref.dart';
import 'package:unit2/model/passo/property_info.dart';
import 'package:unit2/model/passo/structural_materials_ii.dart';
import 'package:unit2/sevices/passo/building/general_description_services.dart';
import 'package:unit2/sevices/passo/building/property_info_services.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/building/structural_material_services.dart';
part 'property_info_event.dart';
part 'property_info_state.dart';
class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
PropertyInfoBloc() : super(PropertyInfoLoading()) {
on<LoadPropertyInfo>((event, emit) async {
emit(PropertyInfoLoading());
try {
final property_info = await PropertyInfoService.instance.fetch();
emit(PropertyInfoLoaded(property_info));
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
});
on<AddPropertyInfo>((event, emit) async {
final state = this.state;
try {
http.Response response =
(await PropertyInfoService.instance.add(event.property_info))!;
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
final tempID = await SharedPreferences.getInstance();
print(jsonResponse['data']);
await tempID.setInt('tempid', jsonResponse['data']['id'] + 1);
final faas = await PropertyInfoService.instance.fetch();
emit(PropertyInfoLoaded(faas));
}
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
});
on<UpdatPropertyInfo>(((event, emit) async {
final state = this.state;
try {
http.Response response = (await PropertyInfoService.instance
.update(event.property_info, event.property_info.id))!;
print('property_info');
print(response.body);
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
}));
on<UpdateBldgLoc>(((event, emit) async {
final state = this.state;
try {
http.Response response = (await PropertyInfoService.instance
.updateBldg(event.bldg_loc, event.bldg_loc.id))!;
print('bldgLoc');
print(response.statusCode);
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
}));
on<UpdateLandRef>(
(event, emit) async {
final state = this.state;
try {
http.Response response = (await PropertyInfoService.instance
.updateLandRef(event.land_ref, event.land_ref.id))!;
print('landref');
print(response.body);
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
},
);
on<UpdateGeneralDesc>((event, emit) async {
final state = this.state;
try {
http.Response response = (await PropertyInfoService.instance
.updateGenDesc(event.gen_desc, event.gen_desc.id))!;
print('genDesc');
print(response.body);
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
});
on<UpdateStrucMaterials>((event, emit) async {
final state = this.state;
try {
final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('tempid')! - 1);
http.Response response = (await StrucMaterialServices.instance
.update(event.data, event.data.id))!;
print('struc Material');
print(response.body);
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
});
}
}

View File

@ -25,6 +25,17 @@ class AddPropertyInfo extends PropertyInfoEvent {
List<Object> get props => [property_info];
}
class UpdatPropertyInfo extends PropertyInfoEvent {
// ignore: non_constant_identifier_names
final PropertyInfo property_info;
// ignore: non_constant_identifier_names
const UpdatPropertyInfo({required this.property_info});
@override
List<Object> get props => [property_info];
}
class UpdateBldgLoc extends PropertyInfoEvent {
// ignore: non_constant_identifier_names
final BldgLoc bldg_loc;
@ -45,11 +56,20 @@ class UpdateLandRef extends PropertyInfoEvent {
List<Object> get props => [land_ref];
}
// class UpdateGeneralDesc extends PropertyInfoEvent {
// final GeneralDesc gen_desc;
class UpdateGeneralDesc extends PropertyInfoEvent {
final GeneralDesc gen_desc;
// const UpdateGeneralDesc({required this.gen_desc});
const UpdateGeneralDesc({required this.gen_desc});
// @override
// List<Object> get props => [gen_desc];
// }
@override
List<Object> get props => [gen_desc];
}
class UpdateStrucMaterials extends PropertyInfoEvent {
final StructureMaterialsII data;
const UpdateStrucMaterials({required this.data});
@override
List<Object> get props => [data];
}

View File

@ -0,0 +1,23 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/structural_materials_ii.dart';
import 'package:unit2/model/passo/structureMaterial.dart';
import 'package:unit2/sevices/passo/building/structural_material_services.dart';
part 'structural_material_event.dart';
part 'structural_material_state.dart';
class StructuralMaterialBloc
extends Bloc<StructuralMaterialEvent, StructuralMaterialState> {
StructuralMaterialBloc() : super(StructuralMaterialInitial()) {
on<LoadStructuralMaterial>((event, emit) async {
emit(StructuralMaterialsLoading());
try {
final structure = await StrucMaterialServices.instance.fetch(event.id);
emit(StructuralMaterialsLoaded(structure));
} catch (e) {
emit(StructuralMaterialsErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,18 @@
part of 'structural_material_bloc.dart';
class StructuralMaterialEvent extends Equatable {
const StructuralMaterialEvent();
@override
List<Object> get props => [];
}
class LoadStructuralMaterial extends StructuralMaterialEvent {
final StructureMaterials structure;
final int? id;
const LoadStructuralMaterial({required this.structure, required this.id});
@override
List<Object> get props => [structure];
}

View File

@ -0,0 +1,28 @@
part of 'structural_material_bloc.dart';
class StructuralMaterialState extends Equatable {
const StructuralMaterialState();
@override
List<Object> get props => [];
}
class StructuralMaterialInitial extends StructuralMaterialState {}
class StructuralMaterialsLoading extends StructuralMaterialState {}
class StructuralMaterialsLoaded extends StructuralMaterialState {
const StructuralMaterialsLoaded(this.structure);
final StructureMaterials structure;
@override
List<Object> get props => [structure];
}
class StructuralMaterialsErrorState extends StructuralMaterialState {
const StructuralMaterialsErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -11,7 +11,7 @@ class UnitConstructBloc extends Bloc<UnitConstructEvent, UnitConstructState> {
on<LoadUnitConstruct>((event, emit) async {
emit(UnitConstructLoading());
try {
final unit = await UnitConstructService.instance.getUnitConstruct();
final unit = await UnitConstructService.instance.fetch();
emit(UnitConstructLoaded(unit));
} catch (e) {
emit(UnitConstructErrorState(e.toString()));

View File

@ -0,0 +1,60 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_appr.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/land/land_appraisal.dart';
part 'land_appraisal_event.dart';
part 'land_appraisal_state.dart';
class LandAppraisalBloc extends Bloc<LandAppraisalEvent, LandAppraisalState> {
LandAppraisalBloc() : super(LandAppraisalLoading()) {
List<LandAppr> globalLandAppraisal = [];
on<LoadLandAppraisal>((event, emit) async {
emit(LandAppraisalLoading());
try {
final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('landid'));
final additionalItems =
await LandAppraisalServices.instance.fetch(tempID.getInt('tempid'));
globalLandAppraisal
.addAll(additionalItems); // Append all items to the list
emit(LandAppraisalLoaded(globalLandAppraisal));
} catch (e) {
emit(LandAppraisalErrorState(e.toString()));
}
});
on<AddLandAppraisal>((event, emit) async {
http.Response response =
(await LandAppraisalServices.instance.add(event.land_appr))!;
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
LandAppr newAdditional = LandAppr.fromJson(jsonResponse['data']);
print(jsonResponse['data']);
globalLandAppraisal.add(newAdditional);
emit(LandAppraisalLoaded(globalLandAppraisal));
}
});
on<DeleteLandAppraisal>((event, emit) async {
print(event.id);
http.Response response =
(await LandAppraisalServices.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
globalLandAppraisal
.removeWhere(((LandAppr element) => element.id == event.id));
emit(LandAppraisalDeletedState(success: true));
}
});
on<ShowLandAppraisal>((event, emit) async {
emit(ShowAddLandAppraisalScreen());
});
}
}

View File

@ -0,0 +1,37 @@
part of 'land_appraisal_bloc.dart';
class LandAppraisalEvent extends Equatable {
const LandAppraisalEvent();
@override
List<Object> get props => [];
}
class LoadLandAppraisal extends LandAppraisalEvent {
final List<LandAppr> land_appr;
const LoadLandAppraisal({this.land_appr = const <LandAppr>[]});
@override
List<Object> get props => [land_appr];
}
class AddLandAppraisal extends LandAppraisalEvent {
final LandAppr land_appr;
const AddLandAppraisal({required this.land_appr});
@override
List<Object> get props => [land_appr];
}
class DeleteLandAppraisal extends LandAppraisalEvent {
final int id;
const DeleteLandAppraisal({required this.id});
@override
List<Object> get props => [id];
}
class ShowLandAppraisal extends LandAppraisalEvent {}

View File

@ -0,0 +1,35 @@
part of 'land_appraisal_bloc.dart';
class LandAppraisalState extends Equatable {
const LandAppraisalState();
@override
List<Object> get props => [];
}
class LandAppraisalLoading extends LandAppraisalState {}
class LandAppraisalLoaded extends LandAppraisalState {
const LandAppraisalLoaded(this.land_appr);
final List<LandAppr> land_appr;
@override
List<Object> get props => [land_appr];
}
class ShowAddLandAppraisalScreen extends LandAppraisalState {}
class LandAppraisalErrorState extends LandAppraisalState {
const LandAppraisalErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}
class LandAppraisalDeletedState extends LandAppraisalState {
final bool success;
const LandAppraisalDeletedState({required this.success});
@override
List<Object> get props => [success];
}

View File

@ -0,0 +1,22 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/land_classification.dart';
import 'package:unit2/sevices/passo/land/land_classification.dart';
part 'land_classification_event.dart';
part 'land_classification_state.dart';
class LandClassificationBloc
extends Bloc<LandClassificationEvent, LandClassificationState> {
LandClassificationBloc() : super(LandClassificationLoading()) {
on<LoadLandClassification>((event, emit) async {
emit(LandClassificationLoading());
try {
final classs = await LandClassificationService.instance.fetch();
emit(LandClassificationLoaded(classs));
} catch (e) {
emit(LandClassificationErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,18 @@
part of 'land_classification_bloc.dart';
class LandClassificationEvent extends Equatable {
const LandClassificationEvent();
@override
List<Object> get props => [];
}
class LoadLandClassification extends LandClassificationEvent {
final List<LandClassification> land_classification;
const LoadLandClassification(
{this.land_classification = const <LandClassification>[]});
@override
List<Object> get props => [land_classification];
}

View File

@ -0,0 +1,26 @@
part of 'land_classification_bloc.dart';
class LandClassificationState extends Equatable {
const LandClassificationState();
@override
List<Object> get props => [];
}
class LandClassificationLoading extends LandClassificationState {}
class LandClassificationLoaded extends LandClassificationState {
LandClassificationLoaded(this.land_classification);
final List<LandClassification> land_classification;
@override
List<Object> get props => [land_classification];
}
class LandClassificationErrorState extends LandClassificationState {
LandClassificationErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,57 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_ext.dart';
import 'package:unit2/sevices/passo/land/land_ext.dart';
import 'package:http/http.dart' as http;
part 'land_ext_event.dart';
part 'land_ext_state.dart';
class LandExtBloc extends Bloc<LandExtEvent, LandExtState> {
LandExtBloc() : super(LandExtInitial()) {
List<LandExt> globalLandExt = [];
on<LoadLandExt>((event, emit) async {
emit(LandExtLoading());
try {
final tempID = await SharedPreferences.getInstance();
final assessments =
await LandExtServices.instance.fetch(tempID.getInt('tempid')! + 1);
emit(LandExtLoaded(assessments));
} catch (e) {
emit(LandExtErrorState(e.toString()));
}
});
on<AddLandExt>((event, emit) async {
http.Response response =
(await LandExtServices.instance.add(event.landext))!;
print('landext');
print(response.statusCode);
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
LandExt newAssessment = LandExt.fromJson(jsonResponse['data']);
globalLandExt.add(newAssessment);
emit(LandExtLoaded(globalLandExt));
}
});
on<UpdateLandExt>((event, emit) async {
final tempID = await SharedPreferences.getInstance();
final tempID2 = tempID.getInt('tempid')! - 1;
http.Response response =
(await LandExtServices.instance.update(event.landext, tempID2))!;
print('landext');
print(response.statusCode);
print(response.body);
// if (response.statusCode == 201) {
// final faas = await PropertyInfoRepository.getUsers();
// emit(FaasLoaded(faas));
// }
});
}
}

View File

@ -0,0 +1,37 @@
part of 'land_ext_bloc.dart';
class LandExtEvent extends Equatable {
const LandExtEvent();
@override
List<Object> get props => [];
}
class LoadLandExt extends LandExtEvent {
final List<LandExt> landext;
const LoadLandExt({this.landext = const <LandExt>[]});
@override
List<Object> get props => [landext];
}
class AddLandExt extends LandExtEvent {
final LandExt landext;
const AddLandExt({required this.landext});
@override
List<Object> get props => [landext];
}
class UpdateLandExt extends LandExtEvent {
// ignore: non_constant_identifier_names
final LandExt landext;
// ignore: non_constant_identifier_names
const UpdateLandExt({required this.landext});
@override
List<Object> get props => [landext];
}

View File

@ -0,0 +1,28 @@
part of 'land_ext_bloc.dart';
class LandExtState extends Equatable {
const LandExtState();
@override
List<Object> get props => [];
}
class LandExtInitial extends LandExtState {}
class LandExtLoading extends LandExtState {}
class LandExtLoaded extends LandExtState {
LandExtLoaded(this.landext);
final List<LandExt> landext;
@override
List<Object> get props => [landext];
}
class LandExtErrorState extends LandExtState {
LandExtErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,63 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_property_assessment.dart';
import 'package:unit2/sevices/passo/land/land_property_assessment.dart';
import 'package:http/http.dart' as http;
part 'land_property_assessment_event.dart';
part 'land_property_assessment_state.dart';
class LandPropertyAssessmentBloc
extends Bloc<LandPropertyAssessmentEvent, LandPropertyAssessmentState> {
LandPropertyAssessmentBloc() : super(LandPropertyAssessmentLoading()) {
List<LandPropertyAssessment> globalLandPropertyAssessment = [];
on<LoadLandPropertyAssessment>((event, emit) async {
emit(LandPropertyAssessmentLoading());
try {
final tempID = await SharedPreferences.getInstance();
print(tempID.getInt('landid'));
final additionalItems = await LandPropertyAssessmentServices.instance
.fetch(tempID.getInt('tempid'));
globalLandPropertyAssessment
.addAll(additionalItems); // Append all items to the list
emit(LandPropertyAssessmentLoaded(globalLandPropertyAssessment));
} catch (e) {
emit(LandPropertyAssessmentErrorState(e.toString()));
}
});
on<AddLandPropertyAssessment>((event, emit) async {
http.Response response = (await LandPropertyAssessmentServices.instance
.add(event.assessment))!;
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
LandPropertyAssessment newAdditional =
LandPropertyAssessment.fromJson(jsonResponse['data']);
print(jsonResponse['data']);
globalLandPropertyAssessment.add(newAdditional);
emit(LandPropertyAssessmentLoaded(globalLandPropertyAssessment));
}
});
on<DeleteLandPropertyAssessment>((event, emit) async {
print(event.id);
http.Response response =
(await LandPropertyAssessmentServices.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
globalLandPropertyAssessment.removeWhere(
((LandPropertyAssessment element) => element.id == event.id));
emit(LandPropertyAssessmentDeletedState(success: true));
}
});
on<ShowLandPropertyAssessment>((event, emit) async {
emit(ShowAddLandPropertyAssessmentScreen());
});
}
}

View File

@ -0,0 +1,38 @@
part of 'land_property_assessment_bloc.dart';
class LandPropertyAssessmentEvent extends Equatable {
const LandPropertyAssessmentEvent();
@override
List<Object> get props => [];
}
class LoadLandPropertyAssessment extends LandPropertyAssessmentEvent {
final List<LandPropertyAssessment> assessment;
const LoadLandPropertyAssessment(
{this.assessment = const <LandPropertyAssessment>[]});
@override
List<Object> get props => [assessment];
}
class AddLandPropertyAssessment extends LandPropertyAssessmentEvent {
final LandPropertyAssessment assessment;
const AddLandPropertyAssessment({required this.assessment});
@override
List<Object> get props => [assessment];
}
class DeleteLandPropertyAssessment extends LandPropertyAssessmentEvent {
final int id;
const DeleteLandPropertyAssessment({required this.id});
@override
List<Object> get props => [id];
}
class ShowLandPropertyAssessment extends LandPropertyAssessmentEvent {}

View File

@ -0,0 +1,35 @@
part of 'land_property_assessment_bloc.dart';
class LandPropertyAssessmentState extends Equatable {
const LandPropertyAssessmentState();
@override
List<Object> get props => [];
}
class LandPropertyAssessmentLoading extends LandPropertyAssessmentState {}
class LandPropertyAssessmentLoaded extends LandPropertyAssessmentState {
const LandPropertyAssessmentLoaded(this.assessment);
final List<LandPropertyAssessment> assessment;
@override
List<Object> get props => [assessment];
}
class ShowAddLandPropertyAssessmentScreen extends LandPropertyAssessmentState {}
class LandPropertyAssessmentErrorState extends LandPropertyAssessmentState {
const LandPropertyAssessmentErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}
class LandPropertyAssessmentDeletedState extends LandPropertyAssessmentState {
final bool success;
const LandPropertyAssessmentDeletedState({required this.success});
@override
List<Object> get props => [success];
}

View File

@ -0,0 +1,65 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/land_property_boundaries.dart';
import 'package:unit2/model/passo/land_property_loc.dart';
import 'package:unit2/model/passo/land_property_owner.dart';
import 'package:unit2/sevices/passo/land/land_boundaries.dart';
import 'package:unit2/sevices/passo/land/land_location.dart';
import 'package:unit2/sevices/passo/land/land_property_owner.dart';
import 'package:http/http.dart' as http;
part 'land_property_owner_info_event.dart';
part 'land_property_owner_info_state.dart';
class LandPropertyOwnerInfoBloc
extends Bloc<LandPropertyOwnerInfoEvent, LandPropertyOwnerInfoState> {
LandPropertyOwnerInfoBloc() : super(LandLoading()) {
on<LoadLand>((event, emit) async {
emit(LandLoading());
try {
final faas = await LandServices.instance.fetch();
emit(LandLoaded(faas));
} catch (e) {
emit(LandErrorState(e.toString()));
}
});
on<AddPropertyOwnerLand>((event, emit) async {
http.Response response = (await LandServices.instance.add(event.land))!;
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
var details = jsonResponse['data']['details'];
if (details != null) {
var id = details['id'];
final tempID = await SharedPreferences.getInstance();
print(id);
await tempID.setInt('landid', id + 1);
final faas = await LandServices.instance.fetch();
emit(LandLoaded(faas));
} else {
print("No 'details' object found in the response.");
// Handle the case when 'details' is missing
}
}
});
on<UpdateLandLoc>((event, emit) async {
final state = this.state;
http.Response response = (await LandLocationService.instance
.update(event.land_loc, event.land_loc.id))!;
print('Land LOc');
print(response.body);
});
on<UpdateLandBoundaries>((event, emit) async {
final state = this.state;
http.Response response = (await LandBoundariesService.instance
.update(event.land_boundaries, event.land_boundaries.id))!;
print('Land Boundaries');
print(response.body);
});
}
}

View File

@ -0,0 +1,48 @@
part of 'land_property_owner_info_bloc.dart';
class LandPropertyOwnerInfoEvent extends Equatable {
const LandPropertyOwnerInfoEvent();
@override
List<Object> get props => [];
}
class LoadLand extends LandPropertyOwnerInfoEvent {
final List<LandPropertyOwner> land;
const LoadLand({this.land = const <LandPropertyOwner>[]});
@override
List<Object> get props => [land];
}
class AddPropertyOwnerLand extends LandPropertyOwnerInfoEvent {
final LandPropertyOwner land;
const AddPropertyOwnerLand({required this.land});
@override
List<Object> get props => [land];
}
class UpdateLandLoc extends LandPropertyOwnerInfoEvent {
// ignore: non_constant_identifier_names
final LandPropertyLoc land_loc;
// ignore: non_constant_identifier_names
const UpdateLandLoc({required this.land_loc});
@override
List<Object> get props => [land_loc];
}
class UpdateLandBoundaries extends LandPropertyOwnerInfoEvent {
// ignore: non_constant_identifier_names
final LandPropertyBoundaries land_boundaries;
// ignore: non_constant_identifier_names
const UpdateLandBoundaries({required this.land_boundaries});
@override
List<Object> get props => [land_boundaries];
}

View File

@ -0,0 +1,34 @@
part of 'land_property_owner_info_bloc.dart';
class LandPropertyOwnerInfoState extends Equatable {
const LandPropertyOwnerInfoState();
@override
List<Object> get props => [];
}
class LandLoading extends LandPropertyOwnerInfoState {}
class LandLoaded extends LandPropertyOwnerInfoState {
const LandLoaded(this.land);
final List<LandPropertyOwner> land;
@override
List<Object> get props => [land];
}
// class PropertyAppraisalLoaded extends AssessorsState {
// PropertyAppraisalLoaded(this.appraisal);
// final List<PropertyAppraisal> appraisal;
// @override
// List<Object> get props => [appraisal];
// }
class LandErrorState extends LandPropertyOwnerInfoState {
const LandErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,25 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/land_classification.dart';
import 'package:unit2/model/passo/land_subclassification.dart';
import 'package:unit2/sevices/passo/land/land_classification.dart';
import 'package:unit2/sevices/passo/land/land_subclassification.dart';
part 'land_subclassification_event.dart';
part 'land_subclassification_state.dart';
class LandSubClassificationBloc
extends Bloc<LandSubClassificationEvent, LandSubClassificationState> {
LandSubClassificationBloc() : super(LandSubClassificationLoading()) {
on<LoadLandSubClassification>((event, emit) async {
emit(LandSubClassificationLoading());
try {
final classs = await LandSubClassificationService.instance
.fetch(event.cityCode, event.classCode);
emit(LandSubClassificationLoaded(classs));
} catch (e) {
emit(LandSubClassificationErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,19 @@
part of 'land_subclassification_bloc.dart';
class LandSubClassificationEvent extends Equatable {
const LandSubClassificationEvent();
@override
List<Object> get props => [];
}
class LoadLandSubClassification extends LandSubClassificationEvent {
final String cityCode;
final int classCode;
const LoadLandSubClassification(
{required this.cityCode, required this.classCode});
@override
List<Object> get props => [cityCode, classCode];
}

View File

@ -0,0 +1,26 @@
part of 'land_subclassification_bloc.dart';
class LandSubClassificationState extends Equatable {
const LandSubClassificationState();
@override
List<Object> get props => [];
}
class LandSubClassificationLoading extends LandSubClassificationState {}
class LandSubClassificationLoaded extends LandSubClassificationState {
LandSubClassificationLoaded(this.land_subclassification);
final List<LandSubClassification> land_subclassification;
@override
List<Object> get props => [land_subclassification];
}
class LandSubClassificationErrorState extends LandSubClassificationState {
LandSubClassificationErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,22 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/trees_improvements.dart';
import 'package:unit2/sevices/passo/land/land_trees_improvements.dart';
part 'land_trees_improvements_event.dart';
part 'land_trees_improvements_state.dart';
class LandTreesImprovementsBloc
extends Bloc<LandTreesImprovementsEvent, LandTreesImprovementsState> {
LandTreesImprovementsBloc() : super(LandTreesImprovementsInitial()) {
on<LoadLandTreesImprovements>((event, emit) async {
emit(LandTreesImprovementsLoading());
try {
final trees_imp = await LandTreesImprovementsServices.instance.fetch();
emit(LandTreesImprovementsLoaded(trees_imp));
} catch (e) {
emit(LandTreesImprovementsErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,17 @@
part of 'land_trees_improvements_bloc.dart';
class LandTreesImprovementsEvent extends Equatable {
const LandTreesImprovementsEvent();
@override
List<Object> get props => [];
}
class LoadLandTreesImprovements extends LandTreesImprovementsEvent {
final List<TreesImprovements> trees_imp;
const LoadLandTreesImprovements(
{this.trees_imp = const <TreesImprovements>[]});
@override
List<Object> get props => [trees_imp];
}

View File

@ -0,0 +1,28 @@
part of 'land_trees_improvements_bloc.dart';
class LandTreesImprovementsState extends Equatable {
const LandTreesImprovementsState();
@override
List<Object> get props => [];
}
class LandTreesImprovementsInitial extends LandTreesImprovementsState {}
class LandTreesImprovementsLoading extends LandTreesImprovementsState {}
class LandTreesImprovementsLoaded extends LandTreesImprovementsState {
LandTreesImprovementsLoaded(this.trees_imp);
final List<TreesImprovements> trees_imp;
@override
List<Object> get props => [trees_imp];
}
class LandTreesImprovementsErrorState extends LandTreesImprovementsState {
LandTreesImprovementsErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,59 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/land_value_adjustment.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/sevices/passo/land/land_value_adjustment.dart';
part 'land_value_adjustments_event.dart';
part 'land_value_adjustments_state.dart';
class LandValueAdjustmentsBloc
extends Bloc<LandValueAdjustmentsEvent, LandValueAdjustmentsState> {
LandValueAdjustmentsBloc() : super(LandValueAdjustmentsLoading()) {
List<ValueAdjustments> globalLandValueAdjustments = [];
on<LoadLandValueAdjustments>((event, emit) async {
emit(LandValueAdjustmentsLoading());
try {
// final tempID = await SharedPreferences.getInstance();
// print(tempID.getInt('tempid'));
// final additionalItem = await GetLandValueAdjustments.getLandValueAdjustments(
// tempID.getInt('tempid'));
emit(LandValueAdjustmentsLoaded(globalLandValueAdjustments));
} catch (e) {
emit(LandValueAdjustmentsErrorState(e.toString()));
}
});
on<AddLandValueAdjustments>((event, emit) async {
http.Response response =
(await ValueAdjustmentsServices.instance.add(event.val_adj))!;
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
ValueAdjustments newAdditional =
ValueAdjustments.fromJson(jsonResponse['data']);
print(jsonResponse['data']);
globalLandValueAdjustments.add(newAdditional);
emit(LandValueAdjustmentsLoaded(globalLandValueAdjustments));
}
});
on<DeleteLandValueAdjustments>((event, emit) async {
print(event.id);
http.Response response =
(await ValueAdjustmentsServices.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
globalLandValueAdjustments.removeWhere(
((ValueAdjustments element) => element.id == event.id));
emit(LandValueAdjustmentsDeletedState(success: true));
}
});
on<ShowLandValueAdjustments>((event, emit) async {
emit(ShowAddLandValueAdjustmentsScreen());
});
}
}

View File

@ -0,0 +1,37 @@
part of 'land_value_adjustments_bloc.dart';
class LandValueAdjustmentsEvent extends Equatable {
const LandValueAdjustmentsEvent();
@override
List<Object> get props => [];
}
class LoadLandValueAdjustments extends LandValueAdjustmentsEvent {
final List<ValueAdjustments> val_adj;
const LoadLandValueAdjustments({this.val_adj = const <ValueAdjustments>[]});
@override
List<Object> get props => [val_adj];
}
class AddLandValueAdjustments extends LandValueAdjustmentsEvent {
final ValueAdjustments val_adj;
const AddLandValueAdjustments({required this.val_adj});
@override
List<Object> get props => [val_adj];
}
class DeleteLandValueAdjustments extends LandValueAdjustmentsEvent {
final int id;
const DeleteLandValueAdjustments({required this.id});
@override
List<Object> get props => [id];
}
class ShowLandValueAdjustments extends LandValueAdjustmentsEvent {}

View File

@ -0,0 +1,35 @@
part of 'land_value_adjustments_bloc.dart';
class LandValueAdjustmentsState extends Equatable {
const LandValueAdjustmentsState();
@override
List<Object> get props => [];
}
class LandValueAdjustmentsLoading extends LandValueAdjustmentsState {}
class LandValueAdjustmentsLoaded extends LandValueAdjustmentsState {
const LandValueAdjustmentsLoaded(this.val_adj);
final List<ValueAdjustments> val_adj;
@override
List<Object> get props => [val_adj];
}
class ShowAddLandValueAdjustmentsScreen extends LandValueAdjustmentsState {}
class LandValueAdjustmentsErrorState extends LandValueAdjustmentsState {
const LandValueAdjustmentsErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}
class LandValueAdjustmentsDeletedState extends LandValueAdjustmentsState {
final bool success;
const LandValueAdjustmentsDeletedState({required this.success});
@override
List<Object> get props => [success];
}

View File

@ -0,0 +1,59 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/other_improvements.dart';
import 'package:unit2/sevices/passo/land/land_other_improvements.dart';
import 'package:http/http.dart' as http;
part 'other_improvements_event.dart';
part 'other_improvements_state.dart';
class OtherImprovementsBloc
extends Bloc<OtherImprovementsEvent, OtherImprovementsState> {
OtherImprovementsBloc() : super(OtherImprovementLoading()) {
List<OtherImprovements> globalOtherImprovement = [];
on<LoadOtherImprovement>((event, emit) async {
emit(OtherImprovementLoading());
try {
// final tempID = await SharedPreferences.getInstance();
// print(tempID.getInt('tempid'));
// final additionalItem = await GetOtherImprovement.getOtherImprovement(
// tempID.getInt('tempid'));
emit(OtherImprovementLoaded(globalOtherImprovement));
} catch (e) {
emit(OtherImprovementErrorState(e.toString()));
}
});
on<AddOtherImprovement>((event, emit) async {
http.Response response =
(await OtherImprovementServices.instance.add(event.other_imp))!;
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
OtherImprovements newAdditional =
OtherImprovements.fromJson(jsonResponse['data']);
print(jsonResponse['data']);
globalOtherImprovement.add(newAdditional);
emit(OtherImprovementLoaded(globalOtherImprovement));
}
});
on<DeleteOtherImprovement>((event, emit) async {
print(event.id);
http.Response response =
(await OtherImprovementServices.instance.remove(event.id));
print(response.statusCode);
if (response.statusCode == 200) {
globalOtherImprovement.removeWhere(
((OtherImprovements element) => element.id == event.id));
emit(OtherImprovementDeletedState(success: true));
}
});
on<ShowOtherImprovement>((event, emit) async {
emit(ShowAddOtherImprovementScreen());
});
}
}

View File

@ -0,0 +1,37 @@
part of 'other_improvements_bloc.dart';
class OtherImprovementsEvent extends Equatable {
const OtherImprovementsEvent();
@override
List<Object> get props => [];
}
class LoadOtherImprovement extends OtherImprovementsEvent {
final List<OtherImprovements> other_imp;
const LoadOtherImprovement({this.other_imp = const <OtherImprovements>[]});
@override
List<Object> get props => [other_imp];
}
class AddOtherImprovement extends OtherImprovementsEvent {
final OtherImprovements other_imp;
const AddOtherImprovement({required this.other_imp});
@override
List<Object> get props => [other_imp];
}
class DeleteOtherImprovement extends OtherImprovementsEvent {
final int id;
const DeleteOtherImprovement({required this.id});
@override
List<Object> get props => [id];
}
class ShowOtherImprovement extends OtherImprovementsEvent {}

View File

@ -0,0 +1,35 @@
part of 'other_improvements_bloc.dart';
class OtherImprovementsState extends Equatable {
const OtherImprovementsState();
@override
List<Object> get props => [];
}
class OtherImprovementLoading extends OtherImprovementsState {}
class OtherImprovementLoaded extends OtherImprovementsState {
const OtherImprovementLoaded(this.other_imp);
final List<OtherImprovements> other_imp;
@override
List<Object> get props => [other_imp];
}
class ShowAddOtherImprovementScreen extends OtherImprovementsState {}
class OtherImprovementErrorState extends OtherImprovementsState {
const OtherImprovementErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}
class OtherImprovementDeletedState extends OtherImprovementsState {
final bool success;
const OtherImprovementDeletedState({required this.success});
@override
List<Object> get props => [success];
}

View File

@ -0,0 +1,22 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/type_of_location.dart';
import 'package:unit2/sevices/passo/land/type_of_location.dart';
part 'type_of_location_event.dart';
part 'type_of_location_state.dart';
class TypeOfLocationBloc
extends Bloc<TypeOfLocationEvent, TypeOfLocationState> {
TypeOfLocationBloc() : super(TypeOfLocationInitial()) {
on<LoadTypeOfLocation>((event, emit) async {
emit(TypeOfLocationLoading());
try {
final locType = await TypeOfLocationServices.instance.fetch();
emit(TypeOfLocationLoaded(locType));
} catch (e) {
emit(TypeOfLocationErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,17 @@
part of 'type_of_location_bloc.dart';
class TypeOfLocationEvent extends Equatable {
const TypeOfLocationEvent();
@override
List<Object> get props => [];
}
class LoadTypeOfLocation extends TypeOfLocationEvent {
final List<TypeOfLocation> locType;
const LoadTypeOfLocation({this.locType = const <TypeOfLocation>[]});
@override
List<Object> get props => [locType];
}

View File

@ -0,0 +1,28 @@
part of 'type_of_location_bloc.dart';
class TypeOfLocationState extends Equatable {
const TypeOfLocationState();
@override
List<Object> get props => [];
}
class TypeOfLocationInitial extends TypeOfLocationState {}
class TypeOfLocationLoading extends TypeOfLocationState {}
class TypeOfLocationLoaded extends TypeOfLocationState {
TypeOfLocationLoaded(this.loc_type);
final List<TypeOfLocation> loc_type;
@override
List<Object> get props => [loc_type];
}
class TypeOfLocationErrorState extends TypeOfLocationState {
TypeOfLocationErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,21 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/type_of_road.dart';
import 'package:unit2/sevices/passo/land/type_of_road.dart';
part 'type_of_road_event.dart';
part 'type_of_road_state.dart';
class TypeOfRoadBloc extends Bloc<TypeOfRoadEvent, TypeOfRoadState> {
TypeOfRoadBloc() : super(TypeOfRoadInitial()) {
on<LoadTypeOfRoad>((event, emit) async {
emit(TypeOfRoadLoading());
try {
final roadType = await TypeOfRoadServices.instance.fetch();
emit(TypeOfRoadLoaded(roadType));
} catch (e) {
emit(TypeOfRoadErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,17 @@
part of 'type_of_road_bloc.dart';
class TypeOfRoadEvent extends Equatable {
const TypeOfRoadEvent();
@override
List<Object> get props => [];
}
class LoadTypeOfRoad extends TypeOfRoadEvent {
final List<TypeOfRoad> roadType;
const LoadTypeOfRoad({this.roadType = const <TypeOfRoad>[]});
@override
List<Object> get props => [roadType];
}

View File

@ -0,0 +1,28 @@
part of 'type_of_road_bloc.dart';
class TypeOfRoadState extends Equatable {
const TypeOfRoadState();
@override
List<Object> get props => [];
}
class TypeOfRoadInitial extends TypeOfRoadState {}
class TypeOfRoadLoading extends TypeOfRoadState {}
class TypeOfRoadLoaded extends TypeOfRoadState {
TypeOfRoadLoaded(this.road_type);
final List<TypeOfRoad> road_type;
@override
List<Object> get props => [road_type];
}
class TypeOfRoadErrorState extends TypeOfRoadState {
TypeOfRoadErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -1,13 +0,0 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
part 'location_event.dart';
part 'location_state.dart';
class LocationBloc extends Bloc<LocationEvent, LocationState> {
LocationBloc() : super(LocationInitial()) {
on<LocationEvent>((event, emit) {
// TODO: implement event handler
});
}
}

View File

@ -1,8 +0,0 @@
part of 'location_bloc.dart';
abstract class LocationEvent extends Equatable {
const LocationEvent();
@override
List<Object> get props => [];
}

View File

@ -1,10 +0,0 @@
part of 'location_bloc.dart';
abstract class LocationState extends Equatable {
const LocationState();
@override
List<Object> get props => [];
}
class LocationInitial extends LocationState {}

View File

@ -0,0 +1,21 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/memoranda.dart';
import 'package:unit2/sevices/passo/memoranda.dart';
part 'memoranda_event.dart';
part 'memoranda_state.dart';
class MemorandaBloc extends Bloc<MemorandaEvent, MemorandaState> {
MemorandaBloc() : super(MemorandaInitial()) {
on<LoadMemoranda>((event, emit) async {
emit(MemorandaLoading());
try {
final municipality = await MemorandaServices.instance.fetch();
emit(MemorandaLoaded(municipality));
} catch (e) {
emit(MemorandaErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,16 @@
part of 'memoranda_bloc.dart';
class MemorandaEvent extends Equatable {
const MemorandaEvent();
@override
List<Object> get props => [];
}
class LoadMemoranda extends MemorandaEvent {
final List<Memoranda> memoranda;
const LoadMemoranda({this.memoranda = const <Memoranda>[]});
@override
List<Object> get props => [memoranda];
}

View File

@ -0,0 +1,28 @@
part of 'memoranda_bloc.dart';
class MemorandaState extends Equatable {
const MemorandaState();
@override
List<Object> get props => [];
}
class MemorandaInitial extends MemorandaState {}
class MemorandaLoading extends MemorandaState {}
class MemorandaLoaded extends MemorandaState {
MemorandaLoaded(this.memorada);
final List<Memoranda> memorada;
@override
List<Object> get props => [memorada];
}
class MemorandaErrorState extends MemorandaState {
MemorandaErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -0,0 +1,21 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/city.dart';
import 'package:unit2/sevices/passo/municipality.dart';
part 'municipality_event.dart';
part 'municipality_state.dart';
class MunicipalityBloc extends Bloc<MunicipalityEvent, MunicipalityState> {
MunicipalityBloc() : super(MunicipalityInitial()) {
on<LoadMunicipality>((event, emit) async {
emit(MunicipalityLoading());
try {
final municipality = await MunicipalityServices.instance.fetch();
emit(MunicipalityLoaded(municipality));
} catch (e) {
emit(MunicipalityErrorState(e.toString()));
}
});
}
}

View File

@ -0,0 +1,17 @@
part of 'municipality_bloc.dart';
class MunicipalityEvent extends Equatable {
const MunicipalityEvent();
@override
List<Object> get props => [];
}
class LoadMunicipality extends MunicipalityEvent {
final List<City> municipality;
const LoadMunicipality({this.municipality = const <City>[]});
@override
List<Object> get props => [municipality];
}

View File

@ -0,0 +1,28 @@
part of 'municipality_bloc.dart';
class MunicipalityState extends Equatable {
const MunicipalityState();
@override
List<Object> get props => [];
}
class MunicipalityInitial extends MunicipalityState {}
class MunicipalityLoading extends MunicipalityState {}
class MunicipalityLoaded extends MunicipalityState {
MunicipalityLoaded(this.municipality);
final List<City> municipality;
@override
List<Object> get props => [municipality];
}
class MunicipalityErrorState extends MunicipalityState {
MunicipalityErrorState(this.error);
final String error;
@override
List<Object> get props => [error];
}

View File

@ -1,59 +0,0 @@
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/model/passo/bldg_loc.dart';
import 'package:unit2/model/passo/land_ref.dart';
import 'package:unit2/model/passo/property_info.dart';
import 'package:unit2/sevices/passo/building/property_info_services.dart';
import 'package:http/http.dart' as http;
part 'property_info_event.dart';
part 'property_info_state.dart';
class PropertyInfoBloc extends Bloc<PropertyInfoEvent, PropertyInfoState> {
PropertyInfoBloc() : super(PropertyInfoLoading()) {
on<LoadPropertyInfo>((event, emit) async {
emit(PropertyInfoLoading());
try {
final property_info =
await PropertyInfoService.instance.getpropertyInfo();
emit(PropertyInfoLoaded(property_info));
} catch (e) {
emit(PropertyInfoErrorState(e.toString()));
}
});
on<AddPropertyInfo>((event, emit) async {
final state = this.state;
http.Response response = (await PropertyInfoService.instance
.postPropertyInfo(event.property_info))!;
print(response.body);
if (response.statusCode == 201) {
var jsonResponse = jsonDecode(response.body);
final tempID = await SharedPreferences.getInstance();
print(jsonResponse['data']);
await tempID.setInt('tempid', jsonResponse['data']['id'] + 1);
final faas = await PropertyInfoService.instance.getpropertyInfo();
emit(PropertyInfoLoaded(faas));
}
});
on<UpdateBldgLoc>(((event, emit) async {
final state = this.state;
http.Response response = (await PropertyInfoService.instance
.bldgLocPutInfo(event.bldg_loc, event.bldg_loc.id))!;
print('bldgLoc');
print(response.statusCode);
}));
on<UpdateLandRef>(
(event, emit) async {
final state = this.state;
http.Response response = (await PropertyInfoService.instance
.landRefPutInfo(event.land_ref, event.land_ref.id))!;
print('landref');
print(response.statusCode);
},
);
}
}

View File

@ -11,7 +11,7 @@ class SignatoriesBloc extends Bloc<SignatoriesEvent, SignatoriesState> {
on<SignatoriesEvent>((event, emit) async {
emit(SignatoriesLoading());
try {
final signatories = await SignatoriesServices.instance.getSignatories();
final signatories = await SignatoriesServices.instance.fetch();
emit(SignatoriesLoaded(signatories));
} catch (e) {
emit(SignatoriesErrorState(e.toString()));

View File

@ -0,0 +1,45 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/sevices/roles/rbac_services.dart';
import '../../model/rbac/new_permission.dart';
import '../../model/rbac/rbac.dart';
part 'rbac_event.dart';
part 'rbac_state.dart';
class RbacBloc extends Bloc<RbacEvent, RbacState> {
RbacBloc() : super(RbacInitial()) {
List<RBAC>? modules;
List<RBAC>? objects;
List<RBAC>? roles;
List<RBACPermission>? permissions;
List<RBAC>? operations;
on<SetRbacScreen>((event, emit) async {
emit(RbacLoadingState());
try {
modules = await RbacServices.instance.getModules();
objects = await RbacServices.instance.getObjects();
roles = await RbacServices.instance.getRole();
permissions = await RbacServices.instance.getPermission();
operations = await RbacServices.instance.getOperations();
emit(RbacScreenSetted(modules: modules!, objects: objects!, operations: operations!, permission: permissions!, role: roles!));
} catch (e) {
emit(RbacErrorState(message: e.toString()));
}
});on<AssignedRbac>((event, emit)async{
try{
emit(RbacLoadingState());
Map responseStatus = await RbacServices.instance.assignRBAC(assigneeId: event.assigneeId, assignerId: event.assignerId, selectedRole: event.selectedRole, selectedModule: event.selectedModule, permissionId: event.permissionId, newPermissions: event.newPermissions);
emit(RbacAssignedState(responseStatus: responseStatus));
}catch(e){
emit(RbacErrorState(message: e.toString()));
}
});
on<LoadRbac>((event,emit){
emit(RbacScreenSetted(modules: modules!, objects: objects!, operations: operations!, permission: permissions!, role: roles!));
});
}
}

View File

@ -0,0 +1,29 @@
part of 'rbac_bloc.dart';
abstract class RbacEvent extends Equatable {
const RbacEvent();
@override
List<Object> get props => [];
}
class SetRbacScreen extends RbacEvent {}
class AssignedRbac extends RbacEvent {
final int assigneeId;
final int assignerId;
final RBAC? selectedRole;
final RBAC? selectedModule;
final List<int> permissionId;
final List<NewPermission> newPermissions;
const AssignedRbac(
{required this.assigneeId,
required this.assignerId,
required this.newPermissions,
required this.permissionId,
required this.selectedModule,
required this.selectedRole});
}
class LoadRbac extends RbacEvent{
}

View File

@ -0,0 +1,47 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/utils/profile_utilities.dart';
import '../../../../model/utils/category.dart';
import '../../../../sevices/roles/rbac_operations/agency_services.dart';
part 'agency_event.dart';
part 'agency_state.dart';
class AgencyBloc extends Bloc<AgencyEvent, AgencyState> {
AgencyBloc() : super(AgencyInitial()) {
List<Agency> agencies = [];
List<Category> agencyCategory = [];
on<GetAgencies>((event, emit) async {
emit(AgencyLoadingState());
try {
if (agencies.isEmpty) {
agencies = await AgencyServices.instance.getAgencies();
}
if (agencyCategory.isEmpty) {
agencyCategory = await ProfileUtilities.instance.agencyCategory();
}
emit(
AgenciesLoaded(agencies: agencies, agencyCategory: agencyCategory));
} catch (e) {
emit(AgencyErrorState(message: e.toString()));
}
});
on<AddAgency>((event, emit) async {
emit(AgencyLoadingState());
try {
Map<dynamic, dynamic> statusResponse =
await AgencyServices.instance.add(agency: event.agency);
if (statusResponse['success']) {
Agency newAgency = Agency.fromJson(statusResponse['data']);
agencies.add(newAgency);
emit(AgencyAddesState(response: statusResponse));
} else {
emit(AgencyAddesState(response: statusResponse));
}
} catch (e) {
emit(AgencyErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,16 @@
part of 'agency_bloc.dart';
abstract class AgencyEvent extends Equatable {
const AgencyEvent();
@override
List<Object> get props => [];
}
class GetAgencies extends AgencyEvent{
}
class AddAgency extends AgencyEvent{
final Agency agency;
const AddAgency({required this.agency});
}

View File

@ -0,0 +1,33 @@
part of 'agency_bloc.dart';
abstract class AgencyState extends Equatable {
const AgencyState();
@override
List<Object> get props => [];
}
class AgenciesLoaded extends AgencyState {
final List<Agency> agencies;
final List<Category> agencyCategory;
const AgenciesLoaded({required this.agencies, required this.agencyCategory});
}
class AgencyErrorState extends AgencyState {
final String message;
const AgencyErrorState({required this.message});
}
class AgencyLoadingState extends AgencyState {}
class AgencyAddesState extends AgencyState {
final Map<dynamic, dynamic> response;
const AgencyAddesState({required this.response});
}
class AgencyDeletedState extends AgencyState {
final bool success;
const AgencyDeletedState({required this.success});
}
class AgencyInitial extends AgencyState {}

View File

@ -0,0 +1,84 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/sevices/roles/rbac_operations/module_services.dart';
import '../../../../model/rbac/rbac.dart';
part 'module_event.dart';
part 'module_state.dart';
class ModuleBloc extends Bloc<ModuleEvent, ModuleState> {
ModuleBloc() : super(ModuleInitial()) {
List<RBAC> modules = [];
on<GetModule>((event, emit) async {
emit(ModuleLoadingState());
try {
if (modules.isEmpty) {
modules = await RbacModuleServices.instance.getRbacModule();
}
emit(ModuleLoaded(module: modules));
} catch (e) {
emit(ModuleErrorState(message: e.toString()));
}
}); ////Add
on<AddRbacModule>((event, emit) async {
try {
emit(ModuleLoadingState());
Map<dynamic, dynamic> statusResponse = await RbacModuleServices.instance
.add(
name: event.name!,
slug: event.slug,
short: event.shorthand,
id: event.id);
if (statusResponse['success']) {
RBAC newRole = RBAC.fromJson(statusResponse['data']);
modules.add(newRole);
emit(ModuleAddedState(response: statusResponse));
} else {
emit(ModuleAddedState(response: statusResponse));
}
} catch (e) {
emit(ModuleErrorState(message: e.toString()));
}
});
////update
on<UpdateRbacModule>((event, emit) async {
emit(ModuleLoadingState());
try {
Map<dynamic, dynamic> statusResponse = await RbacModuleServices.instance
.update(
name: event.name,
slug: event.slug,
short: event.short,
moduleId: event.moduleId,
createdBy: event.createdBy,
updatedBy: event.updatedBy);
if (statusResponse['success']) {
modules.removeWhere((element) => element.id == event.moduleId);
RBAC newRole = RBAC.fromJson(statusResponse['data']);
modules.add(newRole);
emit(ModuleUpdatedState(response: statusResponse));
} else {
emit(ModuleUpdatedState(response: statusResponse));
}
} catch (e) {
emit(ModuleErrorState(message: e.toString()));
}
});
on<DeleteRbacModule>((event, emit) async {
emit(ModuleLoadingState());
try {
bool success = await RbacModuleServices.instance
.deleteRbacModule(moduleId: event.moduleId);
if (success) {
modules.removeWhere((element) => element.id == event.moduleId);
emit(ModuleDeletedState(success: success));
} else {
emit(ModuleDeletedState(success: success));
}
} catch (e) {
emit(ModuleErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,48 @@
part of 'module_bloc.dart';
abstract class ModuleEvent extends Equatable {
const ModuleEvent();
@override
List<Object> get props => [];
}
class GetModule extends ModuleEvent{
}
class AddRbacModule extends ModuleEvent {
final String? name;
final String? slug;
final String? shorthand;
final int id;
const AddRbacModule(
{required this.id,
required this.name,
required this.shorthand,
required this.slug});
}
class UpdateRbacModule extends ModuleEvent {
final int moduleId;
final String name;
final String? slug;
final String? short;
final int? createdBy;
final int updatedBy;
const UpdateRbacModule({
required this.moduleId,
required this.createdBy,
required this.name,
required this.short,
required this.slug,
required this.updatedBy,
});
}
class DeleteRbacModule extends ModuleEvent {
final int moduleId;
const DeleteRbacModule({required this.moduleId});
}

View File

@ -0,0 +1,36 @@
part of 'module_bloc.dart';
abstract class ModuleState extends Equatable {
const ModuleState();
@override
List<Object> get props => [];
}
class ModuleInitial extends ModuleState {}
class ModuleLoaded extends ModuleState{
final List<RBAC> module;
const ModuleLoaded({required this.module});
}
class ModuleLoadingState extends ModuleState{
}
class ModuleErrorState extends ModuleState{
final String message;
const ModuleErrorState({required this.message});
}
class ModuleAddedState extends ModuleState {
final Map<dynamic, dynamic> response;
const ModuleAddedState({required this.response});
}
class ModuleUpdatedState extends ModuleState {
final Map<dynamic, dynamic> response;
const ModuleUpdatedState({required this.response});
}
class ModuleDeletedState extends ModuleState{
final bool success;
const ModuleDeletedState({required this.success});
}

View File

@ -0,0 +1,76 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/login_data/user_info/module.dart';
import 'package:unit2/model/rbac/rbac_rbac.dart';
import 'package:unit2/sevices/roles/rbac_operations/module_objects_services.dart';
import 'package:unit2/sevices/roles/rbac_operations/object_services.dart';
import '../../../../model/rbac/rbac.dart';
import '../../../../sevices/roles/rbac_operations/module_services.dart';
part 'module_objects_event.dart';
part 'module_objects_state.dart';
class ModuleObjectsBloc extends Bloc<ModuleObjectsEvent, ModuleObjectsState> {
ModuleObjectsBloc() : super(ModuleObjectsInitial()) {
List<ModuleObjects> moduleObjects = [];
List<RBAC> objects = [];
List<RBAC> modules = [];
on<GetModuleObjects>((event, emit) async {
emit(ModuleObjectLoadingState());
try {
if (moduleObjects.isEmpty) {
moduleObjects =
await RbacModuleObjectsServices.instance.getModuleObjects();
}
if (objects.isEmpty) {
objects = await RbacObjectServices.instance.getRbacObjects();
}
if (modules.isEmpty) {
modules = await RbacModuleServices.instance.getRbacModule();
}
emit(ModuleObjectLoadedState(
moduleObjects: moduleObjects, objecs: objects, modules: modules));
} catch (e) {
emit(ModuleObjectsErrorState(message: e.toString()));
}
});
on<AddRbacModuleObjects>((event, emit) async {
try {
emit(ModuleObjectLoadingState());
Map<dynamic, dynamic> statusResponse =
await RbacModuleObjectsServices.instance.add(
assignerId: event.assignerId,
moduleId: event.moduleId,
objectsId: event.objectsId);
if (statusResponse['success']) {
statusResponse['data'].forEach((var permission) {
ModuleObjects newModuleObject = ModuleObjects.fromJson(permission);
moduleObjects.add(newModuleObject);
emit(ModuleObjectAddedState(response: statusResponse));
});
} else {
emit(ModuleObjectAddedState(response: statusResponse));
}
} catch (e) {
emit(ModuleObjectsErrorState(message: e.toString()));
}
});
on<DeleteRbacModuleObject>((event, emit) async {
emit(ModuleObjectLoadingState());
try {
bool success = await RbacModuleObjectsServices.instance
.deleteRbacModuleObject(moduleObjectId: event.moduleObjectId);
if (success) {
moduleObjects
.removeWhere((element) => element.id == event.moduleObjectId);
emit(ModuleObjectDeletedState(success: success));
} else {
emit(ModuleObjectDeletedState(success: success));
}
} catch (e) {
emit(ModuleObjectsErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,26 @@
part of 'module_objects_bloc.dart';
abstract class ModuleObjectsEvent extends Equatable {
const ModuleObjectsEvent();
@override
List<Object> get props => [];
}
class GetModuleObjects extends ModuleObjectsEvent {}
class DeleteRbacModuleObject extends ModuleObjectsEvent {
final int moduleObjectId;
const DeleteRbacModuleObject({required this.moduleObjectId});
}
class AddRbacModuleObjects extends ModuleObjectsEvent {
final int moduleId;
final List<int> objectsId;
final int assignerId;
const AddRbacModuleObjects(
{required this.assignerId,
required this.moduleId,
required this.objectsId});
}

View File

@ -0,0 +1,37 @@
part of 'module_objects_bloc.dart';
abstract class ModuleObjectsState extends Equatable {
const ModuleObjectsState();
@override
List<Object> get props => [];
}
class ModuleObjectsInitial extends ModuleObjectsState {}
class ModuleObjectLoadedState extends ModuleObjectsState {
final List<ModuleObjects> moduleObjects;
final List<RBAC> objecs;
final List<RBAC> modules;
const ModuleObjectLoadedState(
{required this.moduleObjects,
required this.modules,
required this.objecs});
}
class ModuleObjectsErrorState extends ModuleObjectsState {
final String message;
const ModuleObjectsErrorState({required this.message});
}
class ModuleObjectLoadingState extends ModuleObjectsState {}
class ModuleObjectAddedState extends ModuleObjectsState {
final Map<dynamic, dynamic> response;
const ModuleObjectAddedState({required this.response});
}
class ModuleObjectDeletedState extends ModuleObjectsState {
final bool success;
const ModuleObjectDeletedState({required this.success});
}

View File

@ -0,0 +1,87 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/sevices/roles/rbac_operations/object_services.dart';
import '../../../../model/rbac/rbac.dart';
part 'object_event.dart';
part 'object_state.dart';
class ObjectBloc extends Bloc<ObjectEvent, ObjectState> {
ObjectBloc() : super(ObjectInitial()) {
List<RBAC> objects = [];
on<GetObjects>((event, emit) async {
emit(ObjectLoadingState());
try {
if (objects.isEmpty) {
objects = await RbacObjectServices.instance.getRbacObjects();
}
emit(ObjectLoaded(objects: objects));
} catch (e) {
emit(ObjectErrorState(message: e.toString()));
}
});
////Add
on<AddRbacObject>((event, emit) async {
try {
emit(ObjectLoadingState());
Map<dynamic, dynamic> statusResponse = await RbacObjectServices.instance
.add(
name: event.name!,
slug: event.slug,
short: event.shorthand,
id: event.id);
if (statusResponse['success']) {
RBAC newObject = RBAC.fromJson(statusResponse['data']);
objects.add(newObject);
emit(ObjectAddedState(response: statusResponse));
} else {
emit(ObjectAddedState(response: statusResponse));
}
} catch (e) {
emit(ObjectErrorState(message: e.toString()));
}
});
on<UpdateRbacObject>((event, emit) async {
emit(ObjectLoadingState());
try {
Map<dynamic, dynamic> statusResponse = await RbacObjectServices.instance
.update(
name: event.name,
slug: event.slug,
short: event.short,
objectId: event.objectId,
createdBy: event.createdBy,
updatedBy: event.updatedBy);
if (statusResponse['success']) {
objects.removeWhere((element) => element.id == event.objectId);
RBAC newObject = RBAC.fromJson(statusResponse['data']);
objects.add(newObject);
emit(ObjectUpdatedState(response: statusResponse));
} else {
emit(ObjectUpdatedState(response: statusResponse));
}
} catch (e) {
emit(ObjectErrorState(message: e.toString()));
}
});
on<DeleteRbacObject>((event, emit) async {
emit(ObjectLoadingState());
try {
bool success = await RbacObjectServices.instance
.deleteRbacRole(objectId: event.objectId);
if (success) {
objects.removeWhere((element) => element.id == event.objectId);
emit(ObjectDeletedState(success: success));
} else {
emit(ObjectDeletedState(success: success));
}
} catch (e) {
emit(ObjectErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,46 @@
part of 'object_bloc.dart';
abstract class ObjectEvent extends Equatable {
const ObjectEvent();
@override
List<Object> get props => [];
}
class GetObjects extends ObjectEvent{
}
class AddRbacObject extends ObjectEvent {
final String? name;
final String? slug;
final String? shorthand;
final int id;
const AddRbacObject(
{required this.id,
required this.name,
required this.shorthand,
required this.slug});
}
class UpdateRbacObject extends ObjectEvent {
final int objectId;
final String name;
final String? slug;
final String? short;
final int? createdBy;
final int updatedBy;
const UpdateRbacObject({
required this.objectId,
required this.createdBy,
required this.name,
required this.short,
required this.slug,
required this.updatedBy,
});
}
class DeleteRbacObject extends ObjectEvent {
final int objectId;
const DeleteRbacObject({required this.objectId});
}

View File

@ -0,0 +1,36 @@
part of 'object_bloc.dart';
abstract class ObjectState extends Equatable {
const ObjectState();
@override
List<Object> get props => [];
}
class ObjectInitial extends ObjectState {}
class ObjectLoaded extends ObjectState{
final List<RBAC> objects;
const ObjectLoaded({required this.objects});
}
class ObjectLoadingState extends ObjectState{
}
class ObjectErrorState extends ObjectState{
final String message;
const ObjectErrorState({required this.message});
}
class ObjectAddedState extends ObjectState {
final Map<dynamic, dynamic> response;
const ObjectAddedState({required this.response});
}
class ObjectUpdatedState extends ObjectState {
final Map<dynamic, dynamic> response;
const ObjectUpdatedState({required this.response});
}
class ObjectDeletedState extends ObjectState{
final bool success;
const ObjectDeletedState({required this.success});
}

Some files were not shown because too many files have changed in this diff Show More