public Create() { App.localizer.SetLocale(App.defaultCulture); InitializeComponent(); family = new Models.Family(); Title = App.localizeResProvider.GetText("String184"); }
public async Task <ActionResult <Family> > PutFamilies(int id, Models.Family updateFamily) { if (id != updateFamily.Id) { return(BadRequest()); } var existingFamily = await _context.Families.Where(f => f.Id == id).FirstOrDefaultAsync(); EntityExpression.FamilyModelToEntity(existingFamily, updateFamily); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FamiliesExists(id)) { return(NotFound()); } else { throw; } } return(await GetFamilies(id)); }
public Create(Models.Family family) { App.localizer.SetLocale(App.defaultCulture); InitializeComponent(); txtName.Text = family.Name; txtRisk.Text = family.Risk; this.family = family; Title = App.localizeResProvider.GetText("String185"); }
public Detail(Models.Family family) { InitializeComponent(); btnDelete.Clicked += DeleteItem_Clicked; btnEdit.Clicked += EditItem_Clicked; this.family = family; txtName.Text = family.Name; txtPosition.Text = family.Location != null ? family.Location.Name : ""; txtRisk.Text = family.Risk; }
public async Task <ActionResult <Family> > PostFamilies(Models.Family family) { Entities.Families fentity = new Families(); EntityExpression.FamilyModelToEntity(fentity, family); _context.Families.Add(fentity); await _context.SaveChangesAsync(); var result = await GetFamilies(fentity.Id); return(CreatedAtAction("GetFamilies", new { id = fentity.Id }, result)); }
public static void FamilyModelToEntity(Entities.Families fa, Models.Family e) { fa.FatherName = e.FatherName; fa.MotherName = e.MotherName; fa.FatherChineseName = e.FatherChineseName; fa.MotherChineseName = e.MotherChineseName; fa.FatherPhone = e.FatherPhone; fa.MotherPhone = e.MotherPhone; fa.FatherEmail = e.FatherEmail; fa.MotherEmail = e.MotherEmail; fa.SpokenLanguages = e.SpokenLanguages; fa.FatherOccupation = e.FatherOccupation; fa.MotherOccupation = e.MotherOccupation; fa.FatherHelpArea = e.FatherHelpArea; fa.MotherHelpArea = e.MotherHelpArea; fa.Address = e.Address; fa.City = e.City; fa.State = e.State; fa.ZipCode = e.ZipCode; }
async void Save_Clicked(object sender, EventArgs e) { Loading.IsRunning = true; try { App.localizer.SetLocale(App.defaultCulture); RestClient restClient = App.restClient; Models.Family family = new Models.Family(); family.User = App.user; if (family.User == null) { await DisplayAlert(App.localizeResProvider.GetText("Notification"), "String186", "Ok"); } else { if (this.family.FamilyId == 0) { family.Location = locations[picLocation.SelectedIndex]; family.Name = txtName.Text; family.Risk = txtRisk.Text; family.CreatedTime = DateTime.Now; var result = await restClient.PostAsync("families", family); restClient.AddEvent("ADD_FAMILY"); if (result.Equals(ApiStatusConstant.SUCCESS)) { await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String187"), "Ok"); Navigation.RemovePage(this); } else { await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String188"), "Ok"); } } else { var familyUpdate = await restClient.Get <Models.Family>("families/" + this.family.FamilyId); if (familyUpdate != null) { familyUpdate.Name = txtName.Text; familyUpdate.Risk = txtRisk.Text; familyUpdate.User = App.user; familyUpdate.Location = locations[picLocation.SelectedIndex]; var result = await restClient.PutAsync("families", familyUpdate, this.family.FamilyId); restClient.AddEvent("EDIT_FAMILY"); if (result.Equals(ApiStatusConstant.SUCCESS)) { await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String189"), "Ok"); Navigation.RemovePage(this); } else { await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String190"), "Ok"); } } else { await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String191"), "Ok"); } } } } catch { await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String175"), "Ok"); } Loading.IsRunning = false; }