public async Task <IActionResult> CreateElderlyAsync(string Name, char Gender, string Email, string Contact, string Password, string Address, string PostalCode, string SpecialNeeds) { if (ModelState.IsValid) { SubzoneRoot zone = await getZoneAsync(PostalCode); if (zone == null) { TempData["Message"] = "Geocoding failed - check for valid postal code"; //If geocoding fails (no identified subzone), probably because of bad (incorrect) postal code. Sends error. return(View()); } bool success = await DataDALContext.postElderly(Name, Gender, Email, Contact, Password, Address, PostalCode, SpecialNeeds, zone.properties); //Posts the elderly to the FB if (success != true) { TempData["Message"] = "Failed"; return(View()); } return(RedirectToAction("_ViewElderly")); } else { return(View()); } }
public async Task <ActionResult> CreateVolunteerAsync(string Name, string Email, string Password, string Contact, string PostalCode, string AssignedZone) { if (ModelState.IsValid) { SubzoneRoot zone = await getZoneAsync(PostalCode); if (zone == null) { TempData["Message"] = "Geocoding failed - check for valid postal code"; //If geocoding fails (no identified subzone), probably because of bad postal code. Sends error. return(View()); } await DataDALContext.postVolunteer(Name, Email, Password, Contact, PostalCode, zone.properties, AssignedZone); return(RedirectToAction("ViewVol")); } else { return(View()); } }
public async Task <AreaRoot> getUserRequests() { SubzoneList SZList = JsonConvert.DeserializeObject <SubzoneList>(System.IO.File.ReadAllText(@"wwwroot/subzones.geojson")); //Read subzones from JSON file and store them as list of class <Subzone> AreaRoot areaList = new AreaRoot(); var reqList = await firebaseClient .Child("requests") .OnceAsync <IDictionary <string, Object> >(); var itemList = await firebaseClient .Child("items") .OnceAsync <items>(); List <Elderly> elderlyList = await getElderly(); List <items> itemListN = new List <items>(); AreaRoot areaRoot = new AreaRoot(); foreach (var item in itemList) { items itemActual = item.Object; itemActual.ID = item.Key; itemListN.Add(itemActual); } areaRoot.ItemList = itemListN; foreach (var area in reqList) { Request_NEW req = new Request_NEW(); req.ZoneID = area.Key; SubzoneRoot subzone = SZList.features.Find(x => x.properties.Name == req.ZoneID); req.RegionCode = subzone.properties.SUBZONE_N; bool found = true; Area areaN = areaRoot.arealist.Find(x => x.AreaCode == subzone.properties.REGION_C); if (areaN == null) { found = false; areaN = new Area(); areaN.AreaCode = subzone.properties.REGION_C; } foreach (var requestID in area.Object) { Request currReq = JsonConvert.DeserializeObject <Request>(requestID.Value.ToString()); currReq.ID = requestID.Key; currReq.Sender = elderlyList.Find(x => x.ID == currReq.SenderID); foreach (var item in currReq.Contents) { items itemF = itemListN.Find(x => x.ID == item.Key); items itemN = new items(itemF.BgCol, itemF.Icon, itemF.Name, itemF.Name_CL, itemF.Requested, item.Value, itemF.Limit); itemN.ID = item.Key; currReq.addItem(itemN); } currReq.dateCreatedD = DateTimeOffset.FromUnixTimeSeconds(currReq.dateCreated).Date.ToLocalTime(); req.ReqList.Add(currReq); } areaN.ReqList.Add(req); if (!found) { areaRoot.arealist.Add(areaN); } } return(areaRoot); }