コード例 #1
0
        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));
        }
コード例 #2
0
        public IHttpActionResult GetRealEstateInsurance(int id)
        {
            RealEstateInsurance realEstateInsurance = db.RealEstateInsurance.Find(id);

            if (realEstateInsurance == null)
            {
                return(NotFound());
            }

            return(Ok(realEstateInsurance));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }