Example #1
0
        public IHttpActionResult PutClient_Car(Client_Car client_Car)
        {
            int id = client_Car.CC_Id;

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

            if (id != client_Car.CC_Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
 public ClientCarModel Create(Client_Car client_car)
 {
     return(new ClientCarModel()
     {
         CC_Id = client_car.CC_Id,
         DateCreated = (DateTime)client_car.DateCreated,
         Status = client_car.Status,
         TotalCost = (float)client_car.TotalCost,
         ClientId = (int)client_car.ClientId,
         CarId = (int)client_car.CarId
     });
 }
Example #3
0
        public IHttpActionResult PostClient_Car(Client_Car client_Car)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Client_Car.Add(client_Car);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = client_Car.CC_Id }, client_Car));
        }
Example #4
0
 public ClientCarModel Create(Client_Car client_car)
 {
     return(new ClientCarModel()
     {
         CC_Id = client_car.CC_Id,
         DateCreated = (DateTime)client_car.DateCreated,
         Status = client_car.Status,
         TotalCost = (float)client_car.TotalCost,
         ClientId = (int)client_car.ClientId,
         CarId = (int)client_car.CarId,
         CarPayment = client_car.CarPayments.Select(cp => Create(cp)),
         Name = client_car.Car.Name
     });
 }
Example #5
0
        public IHttpActionResult DeleteClient_Car(int id)
        {
            Client_Car client_Car = db.Client_Car.Find(id);

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

            db.Client_Car.Remove(client_Car);
            db.SaveChanges();

            return(Ok(client_Car));
        }