private void ClearChild() { try { generalInfo.Grid.Children.Clear(); demographicInfo.Grid.Children.Clear(); adduserfileds.Grid.Children.Clear(); generalInfo.BindingContext = null; generalInfo.Content = null; demographicInfo.BindingContext = null; demographicInfo.Content = null; adduserfileds.BindingContext = null; adduserfileds.Content = null; this.Children.Clear(); this.BindingContext = null; AddChildViewModel.BindingContext = null; AddChildViewModel = null; } catch (Exception ex) { } GC.Collect(); GC.SuppressFinalize(this); }
public IActionResult Edit(int?id, int groupId, string groupName, int minAge, int maxAge) { if (id == null || id == 0) { return(BadRequest()); } var child = _repository.GetChildren((int)id); if (child == null) { return(NotFound()); } AddChildViewModel viewModel = new AddChildViewModel { Children = child, MinAge = minAge, MaxAge = maxAge }; ViewBag.Group = groupName; return(View(viewModel)); }
public ChildTabbedPage(int offlineStudentId) { try { InitializeComponent(); dataservice = DependencyService.Get <ICommonDataService>(); NavigationPage.SetHasNavigationBar(this, false); generalInfo = new AddGeneralInfoView() { Title = "General Information", Icon = "star" }; demographicInfo = new AddDemographicView() { Title = "Demographics/Programs", Icon = "star" }; adduserfileds = new AddUserFieldView() { Title = "User Identified Fields", Icon = "star" }; On <Xamarin.Forms.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom); Children.Add(generalInfo); Children.Add(demographicInfo); Children.Add(adduserfileds); AddChildViewModel = new ViewModels.AddChildViewModel(offlineStudentId); if (AddChildViewModel != null && AddChildViewModel.FirstName == null) { AddChildViewModel.ReloadCommand.Execute(new object()); } foreach (var child in Children) { child.BindingContext = AddChildViewModel; } MessagingCenter.Subscribe <string>(this, "Error", (arg1) => { try { this.SelectedItem = this.Children[0]; this.CurrentPage = this.Children[0]; } catch (Exception ex) { } }); var saveClicked = new Action(() => { (Children[0] as AddGeneralInfoView).SaveChildTapped(null, null); }); (Children[1] as AddDemographicView).SaveChildAction = saveClicked; (Children[2] as AddUserFieldView).SaveChildAction = saveClicked; } catch (Exception ex) { var x = ex; } dataservice.ClearAddChildContent = null; dataservice.ClearAddChildContent = new Action(ClearChild); }
public ActionResult Add() { var child = new AddChildViewModel(); child.Born = DateTime.Now; return(View(child)); }
public IActionResult Edit(AddChildViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } _repository.Update(viewModel.Children); return(RedirectToAction("Details", "Group", new { id = viewModel.Children.GroupId })); }
public IActionResult Add(int groupId, string groupName, int minAge, int maxAge) { AddChildViewModel viewModel = new AddChildViewModel { Children = new Children { GroupId = groupId }, MinAge = minAge, MaxAge = maxAge }; ViewBag.Group = groupName; return(View(viewModel)); }
public AddChildPage() { InitializeComponent(); _addChildViewModel = new AddChildViewModel(); BindingContext = _addChildViewModel; IReadOnlyCollection <TimeZoneInfo> timeZoneList = TimeZoneInfo.GetSystemTimeZones(); foreach (TimeZoneInfo timeZoneInfo in timeZoneList) { _addChildViewModel.TimeZoneList.Add(timeZoneInfo); } TimeZonePicker.ItemsSource = _addChildViewModel.TimeZoneList; }
public ActionResult Edit(AddChildViewModel model) { if (ModelState.IsValid) { var parentId = this.GetUserId(); var child = this.Data.Children.All().First(c => c.ParentId == parentId); child.Name = model.Name; child.Gender = model.Gender; this.Data.SaveChanges(); return(RedirectToAction("Index")); } TempData["success"] = model.Name + " was successfully added"; return(View(model)); }
public ActionResult Edit() { var parent = this.GetUserId(); var userChild = this.Data.Children.All().FirstOrDefault(c => c.ParentId == parent); var child = new AddChildViewModel(); if (userChild != null) { child.Name = userChild.Name; child.Gender = userChild.Gender; } else { child.Born = DateTime.Now; } return(View(child)); }
public IActionResult ProcessAddChild(AddChildViewModel addChildViewModel) { if (ModelState.IsValid) { var userId = _userManager.GetUserId(User); Child newChild = new Child { Name = addChildViewModel.Name, Gender = addChildViewModel.Gender, DOB = addChildViewModel.DOB, UserId = userId }; context.Children.Add(newChild); context.SaveChanges(); return(Redirect("Index")); } return(View("Add", addChildViewModel)); }
public ActionResult Add(AddChildViewModel model) { if (ModelState.IsValid) { var child = new Models.Child() { Name = model.Name, Born = model.Born == null ? DateTime.Now : DateTime.Parse(model.Born.ToString()), Gender = model.Gender, ParentId = this.User.Identity.GetUserId() }; this.Data.Children.Add(child); this.Data.SaveChanges(); return(RedirectToAction("Index")); } TempData["success"] = model.Name + " was successfully added"; return(View(model)); }
protected override void OnAppearing() { try { if (Family != null) { var result = JsonConvert.DeserializeObject <FamilyModel>(Family); if (result != null) { BindingContext = new AddChildViewModel(result); } } } catch (Exception ex) { Crashes.TrackError(ex); StandardMessagesDisplay.InputToast(ex.Message); } }
public async Task <IActionResult> AddEditChild(AddChildViewModel vm) { if (ModelState.IsValid) { if (string.IsNullOrEmpty(vm.Id)) { if (string.IsNullOrEmpty(vm.FirstName)) { vm.FirstName = $"Baby"; } if (string.IsNullOrEmpty(vm.LastName)) { vm.LastName = $"{LastName}"; } var createDto = VmToDto <AddChildViewModel, ChildInfoDto>(vm); var createResponse = await _accountService.CreateChildAsync(createDto); if (createResponse.StatusCode != HttpStatusCode.OK) { ModelState.AddModelError(string.Empty, createResponse.GetErrors()); return(View(vm)); } var createJson = await createResponse.Content.ReadAsStringAsync(); var createObj = createJson.JsonToObj <UserViewModel>(); vm.Id = createObj.Id; } if (vm.AvatarFile != null) { var response = await _fileService.UploadFileAsync(vm.AvatarFile, vm.Id, UsingForType.Avatar); var json = await response.Content.ReadAsStringAsync(); vm.Avatar = json; } if (vm.BannerFile != null) { var response = await _fileService.UploadFileAsync(vm.BannerFile, vm.Id, UsingForType.Banner); var json = await response.Content.ReadAsStringAsync(); vm.Banner = json; } var editDto = VmToDto <AddChildViewModel, EditProfileDto>(vm); var editResponse = await _accountService.UpdateUserDetailByIdAsync(editDto, vm.Id); if (editResponse.StatusCode == HttpStatusCode.OK) { return(RedirectToAction("Dashboard", "Account")); } ModelState.AddModelError(string.Empty, editResponse.GetErrors()); } return(View(vm)); }
public SaveErrorView(AddChildViewModel addChildViewModel) { InitializeComponent(); BindingContext = new SaveErrorViewModel(addChildViewModel); }