public object Post(PostCustomer request) { Customer paramCustomer = request.customer; if (paramCustomer != null) { try { Db.InsertOnly(() => new Customer { document = paramCustomer.document, name = paramCustomer.name, phone = paramCustomer.phone }); } catch (System.Data.SqlClient.SqlException ex) { return(new ErrorMessageResponse { error = ex.Message }); } Customer responseCustomer = new Customer(); responseCustomer = Db.Select <Customer>(Db.From <Customer>(). Where(c => c.document == paramCustomer.document))[0]; return(responseCustomer); } else { return(new PostCustomerResponse { response = "Customer object can't be null" }); } }
public object Post(PostCustomer request) { var customer = request.ConvertTo <Customer>(); customer.Address = request.ConvertTo <Address>(); Db.Save(customer, true); return(customer); }
public void Can_call_Order_Service() { var client = CreateClient(); var post = new PostCustomer { FirstName = "James", LastName = "Olsen", Street = "Lansdowne Road", ProvinceOrState = "Leinster", City = "Dublin", Country = "Ireland", }; var customer = client.Post(post); var put = post.ConvertTo <PutCustomer>(); put.Id = customer.Id; // don't set the row version to force an optimisitc concurrency exception var customer2 = client.Put(put); Assert.That(customer2.Id, Is.EqualTo(customer.Id)); }
public object Post(PostCustomer request) { return(new CustomerManager().AddCustomer(request.Customer.Id, request.Customer.FirstName, request.Customer.LastName, request.Customer.Number, request.Customer.Email)); }