public ActionResult <string> submitEditChild([FromBody] EditChildViewModel model) { ChildData currentChild = _context.ChildData.Where(c => c.Id.Equals(model.Uid)).FirstOrDefault(); if (currentChild == null) { return(Ok(new { response = "Error no child data to edit" })); } currentChild.FirstName = model.Firstname; currentChild.LastName = model.Lastname; currentChild.Street = model.Street; currentChild.City = model.City; currentChild.Province = model.Province; currentChild.PostalCode = model.PostalCode; currentChild.Country = model.Country; currentChild.Latitude = model.Latitude; currentChild.Longitude = model.Longitude; DateTime newBirth = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay); Debug.WriteLine("wowdude" + model.BirthYear); currentChild.BirthDate = newBirth; _context.ChildData.Update(currentChild); _context.SaveChanges(); return(Ok(new { response = "Successfully Updated Child Data" })); }
protected override void OnAppearing() { try { if (Child != null) { var result = JsonConvert.DeserializeObject <ChildModel>(Child); if (result != null) { BindingContext = new EditChildViewModel(result, Guid.Parse(FamilyId)); } } } catch (Exception ex) { Crashes.TrackError(ex); StandardMessagesDisplay.InputToast(ex.Message); } }
public async Task <IActionResult> Edit(int id, [Bind("ChildId,EmployeeId,FullName,ReportCardId,Image,GradeId,IsDelete,StatusId,NationalCode,Birthday")] EditChildViewModel child, int reportCardId) { if (id != child.ChildId) { return(NotFound()); } if (ModelState.IsValid) { try { Child addChild = new Child() { FullName = child.FullName, ChildId = child.ChildId, Birthday = child.Birthday, EmployeeId = child.EmployeeId, GradeId = child.GradeId, Image = child.Image, NationalCode = child.NationalCode }; await _userServices.EditChildAsync(addChild); await _userServices.UpdateStatusId(reportCardId, child.StatusId); } catch (DbUpdateConcurrencyException) { return(Forbid()); } return(RedirectToAction(nameof(Index))); } var reportCard = _userServices.GetReportCardByChildId(child.ChildId); ViewData["ReportCard"] = reportCard; child.StatusId = reportCard.StatusId; ViewData["EmployeeId"] = new SelectList(_userServices.GetEmployees(), "EmployeeId", "FullName", child.EmployeeId); ViewData["GradeId"] = new SelectList(_userServices.GetAllGrade(), "GradeId", "GradeTitle", child.GradeId); ViewData["StatusItem"] = new SelectList(_userServices.GetAllStatus(), "StatusId", "StatusTitle", reportCard.Status.StatusTitle); return(View(child)); }
public IActionResult EditChild(EditChildViewModel model) { return(Redirect("/")); }
public IActionResult EditChild() { var model = new EditChildViewModel(); return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Address1,Address2,AllergiesDescription,AttendHostChurch,City,ClassroomId,DateOfBirth,DecisionMade,EmergencyContactFirstName,EmergencyContactLastName,EmergencyContactPhone,EmergencyContactChildRelationship,FirstName,Gender,GradeCompleted,GuardianChildRelationship,GuardianEmail,GuardianFirstName,GuardianLastName,GuardianPhone,HasAllergies,HasMedicalCondition,HasMedications,HomeChurch,InvitedBy,LastName,MedicalConditionDescription,MedicationDescription,PlaceChildWithRequest,SessionId,State,Zip")] EditChildViewModel childVM) { if (id != childVM.Id) { return(NotFound()); } if (ModelState.IsValid) { var child = await _context.Children .Where(c => c.Id == childVM.Id && c.VBSId == this.CurrentVBSId && c.VBS.TenantId == this.TenantId) .SingleOrDefaultAsync(); child.VBSId = this.CurrentVBSId; child.Address1 = childVM.Address1; child.Address2 = childVM.Address2; child.AllergiesDescription = childVM.AllergiesDescription; child.AttendHostChurch = childVM.AttendHostChurch; child.City = childVM.City; child.ClassroomId = childVM.ClassroomId; child.DateOfBirth = childVM.DateOfBirth; child.DecisionMade = childVM.DecisionMade; child.EmergencyContactFirstName = childVM.EmergencyContactFirstName; child.EmergencyContactLastName = childVM.EmergencyContactLastName; child.EmergencyContactPhone = childVM.EmergencyContactPhone; child.EmergencyContactChildRelationship = childVM.EmergencyContactChildRelationship; child.FirstName = childVM.FirstName; child.Gender = childVM.Gender; child.GradeCompleted = childVM.GradeCompleted; child.GuardianChildRelationship = childVM.GuardianChildRelationship; child.GuardianEmail = childVM.GuardianEmail; child.GuardianFirstName = childVM.GuardianFirstName; child.GuardianLastName = childVM.GuardianLastName; child.GuardianPhone = childVM.GuardianPhone; child.HomeChurch = childVM.HomeChurch; child.InvitedBy = childVM.InvitedBy; child.HasAllergies = false; child.HasMedicalCondition = false; child.HasMedications = false; child.LastName = childVM.LastName; child.MedicalConditionDescription = childVM.MedicalConditionDescription; child.MedicationDescription = childVM.MedicationDescription; child.PlaceChildWithRequest = childVM.PlaceChildWithRequest; child.SessionId = childVM.SessionId; child.State = childVM.State; child.Zip = childVM.Zip; GetGeoCodeResponse geoResponse = await GeocodeHelper.GetGeoCode(child); if (geoResponse != null) { child.Latitude = geoResponse.Lat; child.Longitude = geoResponse.Long; } if (child.ClassroomId == 0) { child.ClassroomId = null; } try { _context.Update(child); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChildExists(child.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } List <Classroom> classrooms = _context.Classes .Include(c => c.Session) .Where(c => c.VBSId == this.CurrentVBSId) .OrderBy(c => c.Session.Period) .ThenBy(c => c.Grade) .ThenBy(c => c.Name) .ToList(); SelectListItem noneClassSelectItem = new SelectListItem { Value = "0", Text = "None", Selected = true }; List <SelectListItem> assignClassrooms = new List <SelectListItem>(); assignClassrooms.Add(noneClassSelectItem); foreach (Classroom dbClass in classrooms) { SelectListItem assignClass = new SelectListItem(); assignClass.Value = dbClass.Id.ToString(); assignClass.Text = dbClass.Session.Period + " " + dbClass.Grade.GetDisplayName() + " " + dbClass.Name; assignClassrooms.Add(assignClass); } childVM.ClassroomSelectItems = assignClassrooms; ViewData["SessionId"] = new SelectList(_context.Sessions.Where(s => s.VBSId == this.CurrentVBSId), "Id", "Period", childVM.SessionId); return(View(childVM)); }
// GET: Children/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var child = await _context.Children .Where(c => c.Id == id && c.VBSId == this.CurrentVBSId && c.VBS.TenantId == this.TenantId) .SingleOrDefaultAsync(); if (child == null) { return(NotFound()); } EditChildViewModel editVM = new EditChildViewModel { Id = child.Id, Address1 = child.Address1, Address2 = child.Address2, AllergiesDescription = child.AllergiesDescription, AttendHostChurch = child.AttendHostChurch, City = child.City, ClassroomId = child.ClassroomId, DateOfBirth = child.DateOfBirth, DecisionMade = child.DecisionMade, EmergencyContactFirstName = child.EmergencyContactFirstName, EmergencyContactLastName = child.EmergencyContactLastName, EmergencyContactPhone = child.EmergencyContactPhone, EmergencyContactChildRelationship = child.EmergencyContactChildRelationship, FirstName = child.FirstName, Gender = child.Gender, GradeCompleted = child.GradeCompleted, GuardianChildRelationship = child.GuardianChildRelationship, GuardianEmail = child.GuardianEmail, GuardianFirstName = child.GuardianFirstName, GuardianLastName = child.GuardianLastName, GuardianPhone = child.GuardianPhone, HomeChurch = child.HomeChurch, InvitedBy = child.InvitedBy, LastName = child.LastName, MedicalConditionDescription = child.MedicalConditionDescription, MedicationDescription = child.MedicationDescription, PlaceChildWithRequest = child.PlaceChildWithRequest, SessionId = child.SessionId, State = child.State, Zip = child.Zip }; List <Classroom> classrooms = _context.Classes .Include(c => c.Session) .Where(c => c.VBSId == this.CurrentVBSId) .OrderBy(c => c.Session.Period) .ThenBy(c => c.Grade) .ThenBy(c => c.Name) .ToList(); SelectListItem noneClassSelectItem = new SelectListItem { Value = "0", Text = "None", Selected = true }; List <SelectListItem> assignClassrooms = new List <SelectListItem>(); assignClassrooms.Add(noneClassSelectItem); foreach (Classroom dbClass in classrooms) { SelectListItem assignClass = new SelectListItem(); assignClass.Value = dbClass.Id.ToString(); assignClass.Text = dbClass.Session.Period + " " + dbClass.Grade.GetDisplayName() + " " + dbClass.Name; assignClassrooms.Add(assignClass); } editVM.ClassroomSelectItems = assignClassrooms; ViewData["SessionId"] = new SelectList(_context.Sessions.Where(s => s.VBSId == this.CurrentVBSId), "Id", "Period", child.SessionId); return(View(editVM)); }