public IHttpActionResult PutDimCustomer(int id, DimCustomer dimCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dimCustomer.CustomerKey)
            {
                return(BadRequest());
            }

            db.Entry(dimCustomer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DimCustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetDimCustomer(int id)
        {
            DimCustomer dimCustomer = db.DimCustomers.Find(id);

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

            return(Ok(dimCustomer));
        }
Beispiel #3
0
        // POST: odata/Customers
        public IHttpActionResult Post(DimCustomer dimCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DimCustomers.Add(dimCustomer);
            db.SaveChanges();

            return(Created(dimCustomer));
        }
        public IHttpActionResult PostDimCustomer(DimCustomer dimCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DimCustomers.Add(dimCustomer);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = dimCustomer.CustomerKey }, dimCustomer));
        }
Beispiel #5
0
        // DELETE: odata/Customers(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            DimCustomer dimCustomer = db.DimCustomers.Find(key);

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

            db.DimCustomers.Remove(dimCustomer);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult DeleteDimCustomer(int id)
        {
            DimCustomer dimCustomer = db.DimCustomers.Find(id);

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

            db.DimCustomers.Remove(dimCustomer);
            db.SaveChanges();

            return(Ok(dimCustomer));
        }
        private IEnumerable <CustomerDTO> FormationTree(DimCustomer customer)
        {
            var list = new List <CustomerDTO>
            {
                new CustomerDTO
                {
                    HashIdMain = HashHelper.EncryptLong(customer.CustomerKey),
                    LastName   = customer.LastName
                }
            };

            //list.AddRange(customer.InverseIdCustomersNavigation.Select(customer => new CustomerDTO
            //{
            //    HashIdMain = HashHelper.EncryptLong(customer.CustomerKey),
            //    LastName = customer.LastName
            //}));
            return(list);
        }
Beispiel #8
0
        // PUT: odata/Customers(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <DimCustomer> patch)
        {
            Validate(patch.GetInstance());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DimCustomer dimCustomer = db.DimCustomers.Find(key);

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

            patch.Put(dimCustomer);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DimCustomerExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(dimCustomer));
        }