public IHttpActionResult Post(Product product)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     using (UnitOfWork uow = ConnectionHelper.CreateSession()) {
         Product entity = new Product(uow)
         {
             ProductName = product.ProductName,
             Picture     = product.Picture
         };
         uow.CommitChanges();
         return(Created(entity));
     }
 }
 public IHttpActionResult Post(Customer customer)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     using (UnitOfWork uow = ConnectionHelper.CreateSession()) {
         Customer entity = new Customer(uow)
         {
             CustomerID  = customer.CustomerID,
             CompanyName = customer.CompanyName
         };
         uow.CommitChanges();
         return(Created(entity));
     }
 }
 public IHttpActionResult Post(Order order)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     using (UnitOfWork uow = ConnectionHelper.CreateSession()) {
         Order entity = new Order(uow)
         {
             ID          = order.ID,
             Date        = order.Date,
             OrderStatus = order.OrderStatus
         };
         uow.CommitChanges();
         return(Created(entity));
     }
 }
예제 #4
0
 public IHttpActionResult Post(Contract contract)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     using (UnitOfWork uow = ConnectionHelper.CreateSession()) {
         Contract entity = new Contract(uow)
         {
             ID     = contract.ID,
             Date   = contract.Date,
             Number = contract.Number
         };
         uow.CommitChanges();
         return(Created(entity));
     }
 }