public IHttpActionResult PutRealEstateInsurance(int id, RealEstateInsurance realEstateInsurance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != realEstateInsurance.RealEstateInsuranceId) { return(BadRequest()); } db.Entry(realEstateInsurance).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RealEstateInsuranceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetRealEstateInsurance(int id) { RealEstateInsurance realEstateInsurance = db.RealEstateInsurance.Find(id); if (realEstateInsurance == null) { return(NotFound()); } return(Ok(realEstateInsurance)); }
public IHttpActionResult PostRealEstateInsurance(RealEstateInsurance realEstateInsurance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RealEstateInsurance.Add(realEstateInsurance); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = realEstateInsurance.RealEstateInsuranceId }, realEstateInsurance)); }
private void testList() { var client = new Client(); client.FirstName = "Tomasz"; client.SecondName = "Lenart"; ClientData exampleClientData = new ClientData(); exampleClientData.Adress = "Wolska 25"; exampleClientData.PeselNumber = 123456789; exampleClientData.BirthDate = DateTime.Now; client.ClientData = exampleClientData; Discount exampleDiscount = new Discount(); exampleDiscount.ValueOfDiscount = 20; string Pesel = "123456789"; RealEstateInsurance exampleInsurance = new RealEstateInsurance(); client.Discount = exampleDiscount; client.Insurances.RealEstateInsurance.Add(exampleInsurance); items.Add(new Client() { FirstName = "John Doe", SecondName = "Kowalski", ClientData = exampleClientData, Discount = exampleDiscount }); items.Add(new Client() { FirstName = "Bartłomiej", SecondName = "Leja", ClientData = exampleClientData, Discount = exampleDiscount }); items.Add(new Client() { FirstName = "Magdalena", SecondName = "Migas", ClientData = exampleClientData, Discount = exampleDiscount }); items.Add(new Client() { FirstName = "Maciej", SecondName = "Latała", ClientData = exampleClientData, Discount = exampleDiscount }); items.Add(client); clientsList.ItemsSource = items; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(clientsList.ItemsSource); view.SortDescriptions.Add(new System.ComponentModel.SortDescription("SecondName", ListSortDirection.Ascending)); }
public IHttpActionResult DeleteRealEstateInsurance(int id) { RealEstateInsurance realEstateInsurance = db.RealEstateInsurance.Find(id); if (realEstateInsurance == null) { return(NotFound()); } db.RealEstateInsurance.Remove(realEstateInsurance); db.SaveChanges(); return(Ok(realEstateInsurance)); }