public IHttpActionResult PutCustomer(int id, Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
 public override Order Create(MovieShopDBContext ctx, Order t)
 {
     ctx.Entry(t.Customer).State = EntityState.Unchanged;
     ctx.Orders.Add(t);
     ctx.SaveChanges();
     return(t);
 }
        public override bool Delete(MovieShopDBContext ctx, int id)
        {
            Customer o = ctx.Customer.FirstOrDefault(x => x.Id == id);

            ctx.Entry(o).State = EntityState.Deleted;
            ctx.SaveChanges();
            return(true);
        }
 public override Customer Update(MovieShopDBContext ctx, Customer c)
 {
     ctx.Entry(c).State = EntityState.Modified;
     ctx.SaveChanges();
     return(c);
 }
 public override Customer Create(MovieShopDBContext ctx, Customer t)
 {
     ctx.Customer.Add(t);
     ctx.SaveChanges();
     return(t);
 }
Пример #6
0
 public override Movie Create(MovieShopDBContext ctx, Movie t)
 {
     ctx.Movies.Add(t);
     ctx.SaveChanges();
     return(t);
 }
 public override Genre Update(MovieShopDBContext ctx, Genre t)
 {
     ctx.Entry(t).State = EntityState.Modified;
     ctx.SaveChanges();
     return(t);
 }
 public override Genre Create(MovieShopDBContext ctx, Genre t)
 {
     ctx.Genres.Add(t);
     ctx.SaveChanges();
     return(t);
 }