private async void InitializeFromSubmission() { Recycler = await RecyclerDA.GetRecyclerByUsername(Submission.Recycler); if (Recycler != null) { RecyclerUsername = Recycler.Username; } Collector = await CollectorDA.GetCollectorByUsername(Submission.Collector); Material = await MaterialDA.GetMaterialById(Submission.Material); if (Material != null) { MaterialName = Material.MaterialName; } }
private async void CreateSubmissionExecute(object obj) { CreateStatus = string.Empty; Recycler = await RecyclerDA.GetRecyclerByUsername(RecyclerUsername); Material = await MaterialDA.GetMaterialByName(MaterialName); Collector = CollectorViewModel.Collector; if (Recycler == null) { CreateStatus = "Recycler not found!"; } else { if (Material == null) { CreateStatus = "Recycled Material Type not found!"; } else { if (Collector.MaterialCollection.Contains(Material.MaterialID)) { Submission.Recycler = Recycler.Username; Submission.ProposedDate = DateTime.Today; Submission.Collector = Collector.Username; var newGuid = Guid.NewGuid(); string id = Convert.ToBase64String(newGuid.ToByteArray()); Submission.SubmissionID = id.Remove(id.Length - 2, 2); Submission.Status = StatusProposed; Submission.Material = Material.MaterialID; await SubmissionDA.AddSubmission(Submission); UpdateSubmissionForAll(); await Application.Current.MainPage.DisplayAlert("Record Material Submission", "You have successfully recorded the submission.", "OK"); await Application.Current.MainPage.Navigation.PopAsync(); } else { CreateStatus = "You do not collect this type of material!"; } } } }