public async void SubmitFacility() { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); BuildingsViewModel ViewModel = new BuildingsViewModel(); await ViewModel.ExecuteBuildingsCommand(facility.Id); var buildings = ViewModel.Buildings; if (!ValidateForm(facility, buildings.ToList(), messageDialog)) { messageDialog.HideLoading(); return; } facility.Status = "Submitted"; facility.ModifiedUserId = userId; facility.ModifiedDate = new DateTime(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { messageDialog.SendToast("Facility is submitted for approval."); var intent = new Intent(Activity, typeof(MainActivity)); StartActivity(intent); } else { messageDialog.SendToast("Unable to submit facility for approval."); } }
async void SaveButton_Click(object sender, EventArgs e) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); facility.SettlementType = settlementtype.SelectedItem.ToString(); facility.Zoning = zoning.SelectedItem.ToString(); bool isUpdated = await ViewModel.ExecuteUpdateFacilityCommand(facility); if (isUpdated) { editButton.Visibility = ViewStates.Visible; saveButton.Visibility = ViewStates.Gone; isEdit = false; settlementtype.Enabled = false; zoning.Enabled = false; messageDialog.HideLoading(); messageDialog.SendToast("Facility is updated successful."); } else { messageDialog.HideLoading(); messageDialog.SendToast("Facility is not updated successful."); } this.isEdit = false; }
async void Submit_Click(Facility facility) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); BuildingsViewModel ViewModel = new BuildingsViewModel(); await ViewModel.ExecuteBuildingsCommand(facility.Id); var buildings = ViewModel.Buildings; if (!ValidateForm(facility, buildings, messageDialog)) { messageDialog.HideLoading(); return; } facility.Status = "Submitted"; facility.ModifiedUserId = userId; facility.ModifiedDate = new DateTime(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { viewModel.Facilities.Remove(viewModel.Facilities.Where(s => s.Id == facility.Id).Single()); messageDialog.SendToast("Facility is submitted for approval."); var myActivity = (MainActivity)this.activity; myActivity.Recreate(); } else { messageDialog.SendToast("Unable to submitted facility for approval."); } }
private async void SendOTPButton_Click(object sender, EventArgs e) { message.Text = ""; Validations validation = new Validations(); MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!validation.IsValidEmail(username.Text.Trim())) { message.Text = "Please enter username to send one time pin"; messageDialog.HideLoading(); return; } int pin = Convert.ToInt32(GetRandomNumber(5)); await ViewModel.SetOPTForUsersync(username.Text.Trim(), pin); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; changePasswordButton.Visibility = ViewStates.Gone; } else { messageDialog.SendToast("One time pin is sent successfully."); changePasswordButton.Visibility = ViewStates.Visible; string smsMessase = string.Format("Send Me: Confirmation OTP:{0}. Change password", pin); messageDialog.SendSMS(ViewModel.Respond.User.Courier.MobileNumber.Trim(), smsMessase); } messageDialog.HideLoading(); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); SupportActionBar.Title = "Quotes"; MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); var request = Intent.GetStringExtra("request"); Request item = JsonConvert.DeserializeObject <Request>(request); Request = new Request(); Request = item; quotesViewModel = new QuotesViewModel(); await quotesViewModel.GetQuotes(Request); if (quotesViewModel.Quotes.Count > 0) { var contactsAdapter = new ContactsAdapter(this, quotesViewModel.Quotes); var contactsListView = FindViewById <ListView>(Resource.Id.ContactsListView); contactsListView.Adapter = contactsAdapter; contactsListView.ItemClick += ItemClick; SaveQuoteRequest(quotesViewModel.Quotes, Request, quotesViewModel); } else { messageDialog.SendToast("There are no couriers available within 50KM from your pick up location."); Intent intent = new Intent(this, typeof(RequestCourierActivity)); StartActivity(intent); } messageDialog.HideLoading(); }
public async override void OnStart() { base.OnStart(); if (ViewModel.Facilities.Count == 0) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (ap.IsOnline(Application.Context)) { await ViewModel.ExecuteFacilitiesCommand(userId); // await this.SqlLiteManager.SyncFacilitiesFromAPI(ViewModel.Facilities); } else { //await this.SqlLiteManager.GetLocalFacilities(userId); } if (ViewModel.Facilities.Count == 0) { messageDialog.SendMessage("There are no facilities that are assinged to this profile.", "No Facilities Found"); } recyclerView.SetAdapter(adapter = new BrowseFacilitiesAdapter(Activity, ViewModel, userId)); messageDialog.HideLoading(); } refresher.Refresh += Refresher_Refresh; adapter.ItemClick += Adapter_ItemClick; }
private async void ChangePasswordButton_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); EncryptionHelper encryptionHelper = new EncryptionHelper(); message.Text = ""; var _user = new User() { Username = username.Text, Password = encryptionHelper.Encrypt(password.Text, "Passw0rd@SendMe"), }; await ViewModel.ChangePasswordAsync(_user, Convert.ToInt32(oneTimePin.Text.Trim())); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; } else { messageDialog.SendToast("Password is changed successfully."); Finish(); } messageDialog.HideLoading(); }
private async void SaveFacility() { if (appPreferences.IsOnline(Application.Context)) { facility.SettlementType = settlementtype.SelectedItem.ToString(); facility.Zoning = zoning.SelectedItem.ToString(); MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { messageDialog.SendToast("Facility Information is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(facility.Id.ToString()); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save Facility Information."); } } }
private async void SignIn_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); AppPreferences ap = new AppPreferences(Application.Context); messageDialog.ShowLoading(); EncryptionHelper encryptionHelper = new EncryptionHelper(); message.Text = ""; var user = new User() { Username = username.Text, Password = password.Text, }; //if (ap.IsOnline(Application.Context)) //{ user = await ViewModel.ExecuteLoginCommand(user); // this.SqlLiteManager.CreateDatabase(); //await this.SqlLiteManager.InsertUpdateUser(this.SqlLiteManager.MapUserToLocalUser(user)); //} //else { // var locaUser = await SqlLiteManager.GetUser(this.SqlLiteManager.MapUserToLocalUser(user)); // if (locaUser != null) // user = SqlLiteManager.MapLocalUserToUser(locaUser); // else { // user = new User() // { // RespondMessage = "Invaild username or password.", // }; // } //} if (user.RespondMessage != null) { message.Text = user.RespondMessage; } else { var newIntent = new Intent(this, typeof(MainActivity)); newIntent.AddFlags(ActivityFlags.ClearTop); newIntent.AddFlags(ActivityFlags.SingleTop); ap.SaveUserId(user.Id.ToString()); StartActivity(newIntent); Finish(); } messageDialog.HideLoading(); }
private async void SaveDeedInfor() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!ValidateDeedInfo()) { messageDialog.HideLoading(); return; } DeedsInfo.ErFNumber = erfNumber.Text; DeedsInfo.TitleDeedNumber = titleDeedNumber.Text; DeedsInfo.Extent = extentm2.Text; DeedsInfo.OwnerInfomation = ownerInformation.Text; DeedsInfo.FacilityId = Facility.Id; DeedsInfo.CreatedUserId = userId; DeedsInfo.ModifiedDate = DateTime.Now; DeedsInfo.ModifiedUserId = userId; DeedsInfo.CreatedDate = DateTime.Now; bool isSuccess = await ViewModel.AddUpdateDeedsInfoAsync(DeedsInfo); messageDialog.HideLoading(); if (isSuccess) { messageDialog.SendToast("Deeds information is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); appPreferences.SaveFacilityId(Facility.Id.ToString()); Facility.Buildings = new List <Building>(); Facility.DeedsInfo = DeedsInfo; intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(Facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save deed information."); } } }
private async void SaveLocation() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!ValidateLocation()) { messageDialog.HideLoading(); return; } Location.LocalMunicipality = localmunicipality.SelectedItem.ToString(); Location.Province = province.SelectedItem.ToString(); Location.StreetAddress = streetAddress.Text; Location.Suburb = suburb.Text; Location.Region = region.Text; Location.BoundryPolygon = _BoundryPolygons; Location.FacilityId = Facility.Id; bool isSuccess = await ViewModel.AddUpdateLocationAsync(Location); messageDialog.HideLoading(); if (isSuccess) { messageDialog.SendToast("Location is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(Facility.Id.ToString()); Facility.Buildings = new List <Building>(); Facility.Location = Location; intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(Facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save location."); } } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_manage_profile); MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); string userId = Intent.GetStringExtra("userId"); ViewModel = new LoginViewModel(); await ViewModel.GetUserById(userId); Initialize(); messageDialog.HideLoading(); // Create your application here }
public async override void OnStart() { base.OnStart(); if (ViewModel.Buildings.Count == 0) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); await ViewModel.ExecuteBuildingsCommand(facilityId); recyclerView.HasFixedSize = true; recyclerView.SetAdapter(adapter = new BrowseBuildingsAdapter(Activity, ViewModel)); messageDialog.HideLoading(); } refresher.Refresh += Refresher_Refresh; adapter.ItemClick += Adapter_ItemClick; }
private async void SignIn_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); EncryptionHelper encryptionHelper = new EncryptionHelper(); message.Text = ""; var user = new User() { Username = username.Text, Password = password.Text, }; if (appPreferences.IsOnline(Application.Context)) { user = await ViewModel.ExecuteLoginCommand(user); if (user.RespondMessage != null) { message.Text = user.RespondMessage; } else { var newIntent = new Intent(this, typeof(MainActivity)); newIntent.AddFlags(ActivityFlags.ClearTop); newIntent.AddFlags(ActivityFlags.SingleTop); appPreferences.SaveUserId(user.Id.ToString()); StartActivity(newIntent); Finish(); } } messageDialog.HideLoading(); }
private async void SignUpButton_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); message.Text = ""; EncryptionHelper encryptionHelper = new EncryptionHelper(); var _user = new User() { Username = username.Text.Trim(), DisplayName = displayName.Text.Trim(), Password = encryptionHelper.Encrypt(password.Text.Trim(), "Passw0rd@SendMe"), UserTypeId = 3, ProfilePicture = Logo, Courier = new Courier() { VehicleBodyTypes = mSelectedItems, MobileNumber = courierMobileNumber.Text.Trim(), PricePerKM = Convert.ToDouble(pricePerKM.Text.Trim()), }, }; await ViewModel.SignUpUser(_user); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; } else { messageDialog.SendToast("You are now registered to provide your service, Login to start making money"); Finish(); } messageDialog.HideLoading(); }
private async void SavePerson() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); Person.FullName = fullname.Text; Person.Designation = designation.Text; Person.PhoneNumber = mobileNumber.Text; Person.EmailAddress = emailaddress.Text; Person.FacilityId = Facility.Id; Person.CreatedUserId = userId; Person.ModifiedDate = DateTime.Now; Person.ModifiedUserId = userId; Person.CreatedDate = DateTime.Now; bool isSuccess = await ViewModel.AddUpdatePersonAsync(Person); messageDialog.HideLoading(); if (isSuccess) { messageDialog.SendToast("Responsible person is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(Facility.Id.ToString()); Facility.Buildings = new List <Building>(); Facility.ResposiblePerson = Person; intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(Facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save responsible person."); } } }
private async void SignUpButton_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); message.Text = ""; var _user = new User() { Username = User.Username, DisplayName = displayName.Text.Trim(), ProfilePicture = Logo, Courier = new Courier() { VehicleBodyTypes = mSelectedItems, MobileNumber = courierMobileNumber.Text.Trim(), PricePerKM = Convert.ToDouble(pricePerKM.Text.Trim()), }, }; await ViewModel.UpdateUserAsync(_user); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; } else { messageDialog.SendToast("Profile is updated successfully."); Finish(); } messageDialog.HideLoading(); }
private async void SaveFacility() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (imageNames.Count() == 0) { imageNames = new List <string>(); } if (FirstPhotoIsChanged) { string thisFileName = appPreferences.SaveImage(((BitmapDrawable)facilityPhoto.Drawable).Bitmap); if (imageNames.Count() > 0) { imageNames[0] = thisFileName; } else { imageNames.Add(thisFileName); } } if (SecondPhotoIsChanged) { var _fileName = String.Format("facility_{0}", Guid.NewGuid()); appPreferences.SaveImage(((BitmapDrawable)secondFacilityPhoto.Drawable).Bitmap, _fileName); if (imageNames.Count() > 1) { imageNames[1] = _fileName; } else { imageNames.Add(_fileName); } } if (FirstPhotoIsChanged) { facility.IDPicture = ""; foreach (var name in imageNames) { if (!String.IsNullOrEmpty(name)) { if (String.IsNullOrEmpty(facility.IDPicture)) { facility.IDPicture = name; } else { facility.IDPicture = facility.IDPicture + "," + name; } } } } bool isUpdated = await ViewModel.ExecuteUpdateFacilityCommand(facility); if (isUpdated) { PictureViewModel pictureViewModel = new PictureViewModel(); List <Models.Picture> pictures = new List <Models.Picture>(); if (FirstPhotoIsChanged) { Bitmap _bm = ((BitmapDrawable)facilityPhoto.Drawable).Bitmap; string file = ""; if (_bm != null) { MemoryStream stream = new MemoryStream(); _bm.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] ba = stream.ToArray(); file = Base64.EncodeToString(ba, Base64.Default); } Models.Picture picture = new Models.Picture() { Name = imageNames[0], File = file, }; pictures.Add(picture); } if (SecondPhotoIsChanged && imageNames.Count() > 1) { Bitmap _bm = ((BitmapDrawable)secondFacilityPhoto.Drawable).Bitmap; string file = ""; if (_bm != null) { MemoryStream stream = new MemoryStream(); _bm.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] ba = stream.ToArray(); file = Base64.EncodeToString(ba, Base64.Default); } Models.Picture picture = new Models.Picture() { Name = imageNames[1], File = file, }; pictures.Add(picture); } bool isSuccess = await pictureViewModel.ExecuteSavePictureCommand(pictures); messageDialog.HideLoading(); messageDialog.SendToast("Pictures are saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(facility.Id.ToString()); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(facility)); this.StartActivity(intent); Finish(); } else { messageDialog.HideLoading(); messageDialog.SendToast("Pictures are not saved successful."); } } }
async void SaveButton_Click(object sender, EventArgs e) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!ValidateForm()) { messageDialog.HideLoading(); return; } StaticData staticData = new StaticData(); int numberOfFloors = 0; if (!String.IsNullOrEmpty(nooOfFoors.Text)) { numberOfFloors = Convert.ToInt32(nooOfFoors.Text); } if (PhotoIsChanged) { FileName = SaveImage(((BitmapDrawable)buildingPhoto.Drawable).Bitmap); } Building item = new Building { Id = building.Id, BuildingName = buildingName.Text, BuildingNumber = building.Id == 0 ? facilityId + staticData.RandomDigits(10) : building.BuildingNumber, BuildingType = buildingType.SelectedItem.ToString(), BuildingStandard = buildingstandard.SelectedItem.ToString(), Status = utilisationStatus.Text, NumberOfFloors = numberOfFloors, FootPrintArea = Convert.ToDouble(totalFootprintAream2.Text), ImprovedArea = Convert.ToDouble(totalImprovedaAeam2.Text), Heritage = heritage.Checked == true ? true :false, OccupationYear = occupationYear.Text, DisabledAccess = disabledAccesss.SelectedItem.ToString(), DisabledComment = disabledComment.Text, ConstructionDescription = constructionDescription.Text, GPSCoordinates = _GPSCoordinates, Photo = PhotoIsChanged == true ? FileName : building.Photo, CreatedDate = new DateTime(), CreatedUserId = userId, ModifiedUserId = userId, Facility = new Facility { Id = facilityId } }; bool isAdded = false; if (!isEdit) { isAdded = await ViewModel.AddBuildingAsync(item); } else { isAdded = await ViewModel.UpdateBuildingAsync(item); } if (isAdded) { if (PhotoIsChanged) { PictureViewModel pictureViewModel = new PictureViewModel(); Bitmap _bm = ((BitmapDrawable)buildingPhoto.Drawable).Bitmap; string bal = ""; if (_bm != null) { MemoryStream stream = new MemoryStream(); _bm.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] ba = stream.ToArray(); bal = Base64.EncodeToString(ba, Base64.Default); } Models.Picture picture = new Models.Picture() { Name = FileName, File = bal, }; List <Models.Picture> pictures = new List <Models.Picture>(); pictures.Add(picture); await pictureViewModel.ExecuteSavePictureCommand(pictures); } messageDialog.HideLoading(); if (!isEdit) { messageDialog.SendToast("Building is added successful."); } else { messageDialog.SendToast("Building is updated successful."); } Finish(); } else { messageDialog.HideLoading(); if (!isEdit) { messageDialog.SendToast("Unable to add new building."); } else { messageDialog.SendToast("Unable to update building."); } } }