public ActionResult Location_Destroy([DataSourceRequest] DataSourceRequest request, VolunteerLocationModel location) { Location target = db.Locations.Find(location.locationId); db.Locations.Remove(target); db.SaveChanges(); return Json(ModelState.ToDataSourceResult()); }
public ActionResult Location_Create([DataSourceRequest] DataSourceRequest request, VolunteerLocationModel location) { int id = 0; var session = HttpContext.Session; if (session != null) { if (session["VolunteerId"] != null) { id = int.Parse(session["VolunteerId"].ToString()); } } if (location != null) { Location target = new Location(); if (db.Locations.Where(m => m.locationId == location.locationId).FirstOrDefault() == null) { target.volunteerId = id; target.locationType = location.locationType; target.address = location.address; target.city = location.city; target.province = location.province; target.postalcode = stringToUpperCase(location.postalcode); db.Locations.Add(target); db.SaveChanges(); } } return Json(ModelState.ToDataSourceResult()); }
private void UpdateLocation(VolunteerLocationModel model) { if (model != null && ModelState.IsValid) { { var target = db.Locations.Find(model.locationId); target.locationType = model.locationType; target.address = model.address; target.city = model.city; target.province = model.province; target.postalcode = stringToUpperCase(model.postalcode); db.Entry(target).State = EntityState.Modified; db.SaveChanges(); } } }
public void CreateLocationForNewVolunteer(VolunteerLocationModel model) { Location location = new Location(); location.volunteerId = model.volunteerId; location.locationType = model.locationType; if (model.locationType == "International") { location.address = convertNullToString(model.address); location.city = ""; location.province = ""; location.country = ""; location.postalcode = ""; } else { location.address = convertNullToString(model.address); location.city = stringToTitleCase(convertNullToString(model.city)); location.province = convertNullToString(model.province); location.country = stringToTitleCase(convertNullToString(model.country)); location.postalcode = convertNullToString(model.postalcode).ToUpper(); } db.Locations.Add(location); db.SaveChanges(); }
private void CreateLocation(VolunteerLocationModel model) { if (model != null) { Location target = new Location(); if (db.Locations.Where(m => m.locationId == model.locationId).FirstOrDefault() == null) { target.volunteerId = model.volunteerId; target.locationType = model.locationType; target.address = model.address; target.city = model.city; target.province = model.province; target.postalcode = stringToUpperCase(model.postalcode); db.Locations.Add(target); db.SaveChanges(); } } }