public RepScheduleEntity(DbContextOptions <RepScheduleEntity> options) : base(options) { if (!Doctors.Any() && !Representatives.Any()) { Doctors.AddRange( new Doctor { Id = 1, Name = "Doctor1", ContactNumber = "987654321", TreatingAilment = "Orthopaedics" }, new Doctor { Id = 2, Name = "Doctor2", ContactNumber = "987654321", TreatingAilment = "General" }, new Doctor { Id = 3, Name = "Doctor3", ContactNumber = "987654321", TreatingAilment = "Gynaecology" }, new Doctor { Id = 4, Name = "Doctor4", ContactNumber = "987654321", TreatingAilment = "General" }, new Doctor { Id = 5, Name = "Doctor5", ContactNumber = "987654321", TreatingAilment = "Gynaecology" }); Representatives.AddRange( new Representative { Id = 1, Name = "Adam" }, new Representative { Id = 2, Name = "Charlie" }, new Representative { Id = 3, Name = "Matthew" } ); SaveChanges(); } }
public async Task <IHttpActionResult> PutRepresentatives(int id, Representatives representatives) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != representatives.Id) { return(BadRequest()); } db.Entry(representatives).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RepresentativesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void LoadData() { StreamResourceInfo srSenate = Application.GetResourceStream(new Uri("Congress411;component/Data/Senate.xml", UriKind.Relative)); XDocument senatorsXml = XDocument.Load(srSenate.Stream); var senateList = (from politician in senatorsXml.Descendants("Politician") select new PoliticianViewModel { BioGuideId = politician.Element("BioGuideId").Value, FirstName = politician.Element("FirstName").Value, LastName = politician.Element("LastName").Value, GovTrackId = politician.Element("GovTrackId").Value, Party = politician.Element("Party").Value, Phone = politician.Element("Phone").Value, TwitterId = politician.Element("TwitterId").Value, State = politician.Element("State").Value, WebSite = politician.Element("WebSite").Value, OfficeAddress = politician.Element("OfficeAddress").Value, SmallImage = String.Format("./Images/{0}.jpg", politician.Element("BioGuideId").Value) }).OrderBy(p => p.LastName).ToList(); foreach (var senator in senateList) { Senators.Add(senator); } senateList = null; StreamResourceInfo srHouse = Application.GetResourceStream(new Uri("Congress411;component/Data/House.xml", UriKind.Relative)); XDocument repsXml = XDocument.Load(srHouse.Stream); var repList = (from politician in repsXml.Descendants("Politician") select new PoliticianViewModel { BioGuideId = politician.Element("BioGuideId").Value, FirstName = politician.Element("FirstName").Value, LastName = politician.Element("LastName").Value, GovTrackId = politician.Element("GovTrackId").Value, Party = politician.Element("Party").Value, Phone = politician.Element("Phone").Value, TwitterId = politician.Element("TwitterId").Value, State = politician.Element("State").Value, WebSite = politician.Element("WebSite").Value, OfficeAddress = politician.Element("OfficeAddress").Value, SmallImage = String.Format("./Images/{0}.jpg", politician.Element("BioGuideId").Value) }).OrderBy(p => p.LastName).ToList(); foreach (var rep in repList) { Representatives.Add(rep); } repList = null; this.IsDataLoaded = true; }
public async Task <IHttpActionResult> GetRepresentatives(int id) { Representatives representatives = await db.Representatives.FindAsync(id); if (representatives == null) { return(NotFound()); } return(Ok(representatives)); }
public async Task <IHttpActionResult> PostRepresentatives(Representatives representatives) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Representatives.Add(representatives); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = representatives.Id }, representatives)); }
public async Task <IHttpActionResult> DeleteRepresentatives(int id) { Representatives representatives = await db.Representatives.FindAsync(id); if (representatives == null) { return(NotFound()); } db.Representatives.Remove(representatives); await db.SaveChangesAsync(); return(Ok(representatives)); }
public override string ToString() { return("VATEntity: [name = " + Name + ", nip = " + NIP + ", regon = " + REGON + ", krs = " + KRS + ", residenceAddress = " + ResidenceAddress + ", workingAddress = " + WorkingAddress + ", vatStatus = " + VATStatus + ", vatResult = " + VATResult + ", representatives = [" + string.Join(", ", Representatives.ConvertAll(e => Convert.ToString(e)).ToArray()) + "]" + ", authorizedClerks = [" + string.Join(", ", AuthorizedClerks.ConvertAll(e => Convert.ToString(e)).ToArray()) + "]" + ", partners = [" + string.Join(", ", Partners.ConvertAll(e => Convert.ToString(e)).ToArray()) + "]" + ", ibans = [" + string.Join(", ", IBANs.ConvertAll(e => Convert.ToString(e)).ToArray()) + "]" + ", hasVirtualAccounts = " + HasVirtualAccounts + ", registrationLegalDate = " + RegistrationLegalDate + ", registrationDenialDate = " + RegistrationDenialDate + ", registrationDenialBasis = " + RegistrationDenialBasis + ", restorationDate = " + RestorationDate + ", restorationBasis = " + RestorationBasis + ", removalDate = " + RemovalDate + ", removalBasis = " + RemovalBasis + "]"); }