public string AddSchool(SchoolDistrict info, int mode, Guid userId, string AgencyId) { try { command.Connection = Connection; command.CommandText = "SP_addschooldist"; command.Parameters.AddWithValue("@mode", mode); command.Parameters.AddWithValue("@SchoolDistrictID", info.SchoolDistrictID); command.Parameters.AddWithValue("@AgencyId", AgencyId); command.Parameters.AddWithValue("@Acronym", (info.Acronym).Trim()); command.Parameters.AddWithValue("@Description", (info.Description).Trim()); command.Parameters.AddWithValue("@TransitionDate", info.TransitionDate); command.Parameters.AddWithValue("@FormalAgreement", info.FormalAgreement); command.Parameters.AddWithValue("@CreatedBy", userId); command.Parameters.AddWithValue("@result", "").Direction = ParameterDirection.Output; command.CommandType = CommandType.StoredProcedure; Connection.Open(); command.ExecuteNonQuery(); Connection.Close(); return(command.Parameters["@result"].Value.ToString()); } catch (Exception ex) { clsError.WriteException(ex); } return(command.Parameters["@result"].Value.ToString()); }
public List <SchoolDistrict> SchoolInfo(out string totalrecord, string sortOrder, string sortDirection, string search, int skip, int pageSize, string userid) { List <SchoolDistrict> _schoollist = new List <SchoolDistrict>(); try { totalrecord = string.Empty; string searchAgency = string.Empty; if (string.IsNullOrEmpty(search.Trim())) { searchAgency = string.Empty; } else { searchAgency = search; } command.Parameters.Add(new SqlParameter("@Search", searchAgency)); command.Parameters.Add(new SqlParameter("@take", pageSize)); command.Parameters.Add(new SqlParameter("@skip", skip)); command.Parameters.Add(new SqlParameter("@sortcolumn", sortOrder)); command.Parameters.Add(new SqlParameter("@sortorder", sortDirection)); command.Parameters.Add(new SqlParameter("@agencyid", userid)); command.Parameters.Add(new SqlParameter("@totalRecord", 0)).Direction = ParameterDirection.Output; command.Connection = Connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "SP_School_list"; DataAdapter = new SqlDataAdapter(command); schooldataTable = new DataTable(); DataAdapter.Fill(schooldataTable); if (schooldataTable.Rows.Count > 0) { for (int i = 0; i < schooldataTable.Rows.Count; i++) { SchoolDistrict addSchoolRow = new SchoolDistrict(); addSchoolRow.SchoolDistrictID = Convert.ToInt32(schooldataTable.Rows[i]["SchoolDistrictID"]); addSchoolRow.Acronym = Convert.ToString(schooldataTable.Rows[i]["Acronym"]); addSchoolRow.Description = Convert.ToString(schooldataTable.Rows[i]["Description"]); addSchoolRow.TransitionDate = Convert.ToString(schooldataTable.Rows[i]["TransitionDate"]); addSchoolRow.FormalAgreement = Convert.ToBoolean(schooldataTable.Rows[i]["FormalAgreement"]); addSchoolRow.CreatedDate = Convert.ToDateTime(schooldataTable.Rows[i]["DateEntered"]).ToString("MM/dd/yyyy"); _schoollist.Add(addSchoolRow); } totalrecord = command.Parameters["@totalRecord"].Value.ToString(); } return(_schoollist); } catch (Exception ex) { totalrecord = string.Empty; clsError.WriteException(ex); return(_schoollist); } finally { DataAdapter.Dispose(); command.Dispose(); schooldataTable.Dispose(); } }
// GET: Counties public ActionResult Index(int?countyId) { PopulatePartialView(); ViewBag.SelectedCounty = (countyId != null) ? db.Counties.Find(countyId) : db.Counties.Find(); List <SchoolDistrict> schoolDistricts = new List <SchoolDistrict>(); var districtInfo = (from schoolDistrict in db.SchoolDistricts where schoolDistrict.CountyID == countyId select new { schoolDistrict }).ToList(); foreach (var value in districtInfo) { SchoolDistrict tempDistrict = new SchoolDistrict(); tempDistrict.Address = value.schoolDistrict.Address; tempDistrict.City = value.schoolDistrict.City; tempDistrict.CountyID = value.schoolDistrict.CountyID; tempDistrict.ID = value.schoolDistrict.ID; tempDistrict.MainPhone = value.schoolDistrict.MainPhone; tempDistrict.NumberOfStudents = value.schoolDistrict.NumberOfStudents; tempDistrict.SchoolName = value.schoolDistrict.SchoolName; tempDistrict.State = value.schoolDistrict.State; tempDistrict.Website = value.schoolDistrict.Website; tempDistrict.Zip = value.schoolDistrict.Zip; schoolDistricts.Add(tempDistrict); } return(View(schoolDistricts)); }
public async Task <SchoolDistrict> AddDistrict(SchoolDistrict district) { VerifyPermission(Permission.ManageSchools); district.Name = district.Name.Trim(); district.SiteId = GetCurrentSiteId(); return(await _schoolDistrictRepository.AddSaveAsync(GetClaimId(ClaimType.UserId), district)); }
/// <summary> /// Creates a new school bus /// </summary> /// <remarks>The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. The field value consists of a single absolute URI. </remarks> /// <param name="item"></param> /// <response code="201">SchoolBus created</response> public virtual IActionResult AddBusAsync(SchoolBus item) { // adjust school bus owner if (item.SchoolBusOwner != null) { int school_bus_owner_id = item.SchoolBusOwner.Id; bool school_bus_owner_exists = _context.SchoolBusOwners.Any(a => a.Id == school_bus_owner_id); if (school_bus_owner_exists) { SchoolBusOwner school_bus_owner = _context.SchoolBusOwners.First(a => a.Id == school_bus_owner_id); item.SchoolBusOwner = school_bus_owner; } } // adjust service area. if (item.ServiceArea != null) { int service_area_id = item.ServiceArea.Id; bool service_area_exists = _context.ServiceAreas.Any(a => a.Id == service_area_id); if (service_area_exists) { ServiceArea service_area = _context.ServiceAreas.First(a => a.Id == service_area_id); item.ServiceArea = service_area; } } // adjust school district if (item.SchoolBusDistrict != null) { int schoolbus_district_id = item.SchoolBusDistrict.Id; bool schoolbus_district_exists = _context.SchoolDistricts.Any(a => a.Id == schoolbus_district_id); if (schoolbus_district_exists) { SchoolDistrict school_district = _context.SchoolDistricts.First(a => a.Id == schoolbus_district_id); item.SchoolBusDistrict = school_district; } } // adjust home city if (item.HomeTerminalCity != null) { int city_id = item.HomeTerminalCity.Id; bool city_exists = _context.Cities.Any(a => a.Id == city_id); if (city_exists) { City city = _context.Cities.First(a => a.Id == city_id); item.HomeTerminalCity = city; } } _context.SchoolBuss.Add(item); _context.SaveChanges(); return(new ObjectResult(item)); }
public async Task <SchoolDistrict> AddDistrict(SchoolDistrict district) { VerifyPermission(Permission.ManageSchools); if (district == null) { throw new GraException("Cannot add empty district."); } district.Name = district.Name.Trim(); district.SiteId = GetCurrentSiteId(); return(await _schoolDistrictRepository.AddSaveAsync(GetClaimId(ClaimType.UserId), district)); }
public async Task UpdateDistrictAsync(SchoolDistrict district) { VerifyPermission(Permission.ManageSchools); var currentDistrict = await _schoolDistrictRepository.GetByIdAsync(district.Id); if (currentDistrict.SiteId != GetCurrentSiteId()) { throw new GraException($"Permission denied - district belongs site id {currentDistrict.SiteId}."); } currentDistrict.Name = district.Name; await _schoolDistrictRepository.UpdateSaveAsync(GetClaimId(ClaimType.UserId), currentDistrict); }
public SchoolDistrictDto(SchoolDistrict model) { this.Id = model.Id; this.Aun = model.Aun; this.Name = model.Name; this.Rate = model.Rate; this.AlternateRate = model.AlternateRate; this.SpecialEducationRate = model.SpecialEducationRate; this.AlternateSpecialEducationRate = model.AlternateSpecialEducationRate; this.PaymentType = model.PaymentType; this.Created = model.Created; this.LastUpdated = model.LastUpdated; }
/// <summary> /// /// </summary> /// <remarks>Updates a school district</remarks> /// <param name="id">id of School District to update</param> /// <param name="item"></param> /// <response code="200">OK</response> /// <response code="404">School District not found</response> public virtual IActionResult SchooldistrictsIdPutAsync(int id, SchoolDistrict item) { var exists = _context.SchoolDistricts.Any(a => a.Id == id); if (exists && id == item.Id) { _context.SchoolDistricts.Update(item); // Save the changes _context.SaveChanges(); return(new ObjectResult(item)); } else { // record not found return(new StatusCodeResult(404)); } }
public SchoolDistrict Getschoolinfo(string SchoolDistrictID, string AgencyId) { SchoolDistrict obj = new SchoolDistrict(); try { command.Parameters.Add(new SqlParameter("@SchoolDistrictID", SchoolDistrictID)); command.Parameters.Add(new SqlParameter("@AgencyId", AgencyId)); command.Connection = Connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "SP_schoolinfo"; DataAdapter = new SqlDataAdapter(command); schooldataTable = new DataTable(); DataAdapter.Fill(schooldataTable); if (schooldataTable != null && schooldataTable.Rows.Count > 0) { obj.SchoolDistrictID = Convert.ToInt32(schooldataTable.Rows[0]["SchoolDistrictID"]); obj.Acronym = schooldataTable.Rows[0]["Acronym"].ToString(); obj.TransitionDate = schooldataTable.Rows[0]["TransitionDate"].ToString(); obj.Description = schooldataTable.Rows[0]["Description"].ToString(); obj.CreatedDate = Convert.ToDateTime(schooldataTable.Rows[0]["DateEntered"]).ToString("MM/dd/yyyy"); obj.FormalAgreement = Convert.ToBoolean(schooldataTable.Rows[0]["FormalAgreement"].ToString()); } DataAdapter.Dispose(); command.Dispose(); schooldataTable.Dispose(); return(obj); } catch (Exception ex) { clsError.WriteException(ex); return(obj); } finally { DataAdapter.Dispose(); command.Dispose(); schooldataTable.Dispose(); } }
public async Task<IActionResult> Update(int id, [FromBody]SchoolDistrictUpdate update) { if (!ModelState.IsValid) return new BadRequestObjectResult(new ErrorsResponse(ModelState)); if (_schoolDistricts.Get(id) == null) return NotFound(); var district = new SchoolDistrict { Id = id, Aun = update.Aun, Name = update.Name, Rate = update.Rate, AlternateRate = update.AlternateRate, SpecialEducationRate = update.SpecialEducationRate, AlternateSpecialEducationRate = update.AlternateSpecialEducationRate, PaymentType = update.PaymentType, }; await Task.Run(() => _context.SaveChanges(() => _schoolDistricts.CreateOrUpdate(district))); return Ok(); }
public virtual IActionResult SchooldistrictsPost([FromBody] SchoolDistrict item) { return(this._service.SchooldistrictsPostAsync(item)); }
public virtual IActionResult SchooldistrictsIdPut([FromRoute] int id, [FromBody] SchoolDistrict item) { return(this._service.SchooldistrictsIdPutAsync(id, item)); }
/// <summary> /// click on the School District menu to load the dashboard page /// </summary> /// <returns>SchoolDistrictDashboardPage</returns> public DashBoardPage DashboardPage() { SchoolDistrict.Click(); return(new DashBoardPage()); }
/// <summary> /// Adjust a SchoolBus item to ensure child object data is in place correctly /// </summary> /// <param name="item"></param> private void AdjustSchoolBus(SchoolBus item) { if (item != null) { if (item.SchoolBusOwner != null) { int school_bus_owner_id = item.SchoolBusOwner.Id; bool school_bus_owner_exists = _context.SchoolBusOwners.Any(a => a.Id == school_bus_owner_id); if (school_bus_owner_exists) { SchoolBusOwner school_bus_owner = _context.SchoolBusOwners.First(a => a.Id == school_bus_owner_id); item.SchoolBusOwner = school_bus_owner; } else // invalid data { item.SchoolBusOwner = null; } } // adjust District. if (item.District != null) { int district_id = item.District.Id; var district_exists = _context.ServiceAreas.Any(a => a.Id == district_id); if (district_exists) { District district = _context.Districts.First(a => a.Id == district_id); item.District = district; } else { item.District = null; } } // adjust school district if (item.SchoolDistrict != null) { int schoolDistrict_id = item.SchoolDistrict.Id; bool schoolDistrict_exists = _context.SchoolDistricts.Any(a => a.Id == schoolDistrict_id); if (schoolDistrict_exists) { SchoolDistrict school_district = _context.SchoolDistricts.First(a => a.Id == schoolDistrict_id); item.SchoolDistrict = school_district; } else // invalid data { item.SchoolDistrict = null; } } // adjust home city if (item.HomeTerminalCity != null) { int city_id = item.HomeTerminalCity.Id; bool city_exists = _context.Cities.Any(a => a.Id == city_id); if (city_exists) { City city = _context.Cities.First(a => a.Id == city_id); item.HomeTerminalCity = city; } else // invalid data { item.HomeTerminalCity = null; } } // adjust inspector if (item.Inspector != null) { int inspector_id = item.Inspector.Id; bool inspector_exists = _context.Users.Any(a => a.Id == inspector_id); if (inspector_exists) { User inspector = _context.Users.First(a => a.Id == inspector_id); item.Inspector = inspector; } else // invalid data { item.Inspector = null; } } // adjust CCWData if (item.CCWData != null) { int ccwdata_id = item.CCWData.Id; bool ccwdata_exists = _context.CCWDatas.Any(a => a.Id == ccwdata_id); if (ccwdata_exists) { CCWData ccwdata = _context.CCWDatas.First(a => a.Id == ccwdata_id); item.CCWData = ccwdata; } else // invalid data { item.CCWData = null; } } } }
/// <summary> /// Creates several school buses /// </summary> /// <remarks>Used for bulk creation of schoolbus records.</remarks> /// <param name="body"></param> /// <response code="201">SchoolBus items created</response> public virtual IActionResult AddSchoolBusBulkAsync(SchoolBus[] items) { if (items == null) { return(new BadRequestResult()); } foreach (SchoolBus item in items) { // adjust school bus owner if (item.SchoolBusOwner != null) { int school_bus_owner_id = item.SchoolBusOwner.Id; bool school_bus_owner_exists = _context.SchoolBusOwners.Any(a => a.Id == school_bus_owner_id); if (school_bus_owner_exists) { SchoolBusOwner school_bus_owner = _context.SchoolBusOwners.First(a => a.Id == school_bus_owner_id); item.SchoolBusOwner = school_bus_owner; } } // adjust service area. if (item.ServiceArea != null) { int service_area_id = item.ServiceArea.Id; bool service_area_exists = _context.ServiceAreas.Any(a => a.Id == service_area_id); if (service_area_exists) { ServiceArea service_area = _context.ServiceAreas.First(a => a.Id == service_area_id); item.ServiceArea = service_area; } } // adjust school district if (item.SchoolBusDistrict != null) { int schoolbus_district_id = item.SchoolBusDistrict.Id; bool schoolbus_district_exists = _context.SchoolDistricts.Any(a => a.Id == schoolbus_district_id); if (schoolbus_district_exists) { SchoolDistrict school_district = _context.SchoolDistricts.First(a => a.Id == schoolbus_district_id); item.SchoolBusDistrict = school_district; } } // adjust home city if (item.HomeTerminalCity != null) { int city_id = item.HomeTerminalCity.Id; bool city_exists = _context.Cities.Any(a => a.Id == city_id); if (city_exists) { City city = _context.Cities.First(a => a.Id == city_id); item.HomeTerminalCity = city; } } var exists = _context.SchoolBuss.Any(a => a.Id == item.Id); if (exists) { _context.SchoolBuss.Update(item); } else { _context.SchoolBuss.Add(item); } } // Save the changes _context.SaveChanges(); return(new NoContentResult()); }
public void SetValues(SchoolPeriod schoolPeriod, ReportingPeriod reportingPeriod, School school, SchoolDistrict district) { SetValue(CommonPlacholder.DistrictName, district.Name); SetValue(CommonPlacholder.PeriodName, reportingPeriod.Name); SetValue(CommonPlacholder.SchoolName, school.Name); }
/// <summary> /// Setup the test. /// </summary> public SchoolDistrictModelTests() { instance = new SchoolDistrict(); }
/// <summary> /// /// </summary> /// <remarks>Adds a school district</remarks> /// <param name="item"></param> /// <response code="200">OK</response> public virtual IActionResult SchooldistrictsPostAsync(SchoolDistrict item) { _context.SchoolDistricts.Add(item); _context.SaveChanges(); return(new ObjectResult(item)); }