public IHttpActionResult PutCustomerV1(int id, CustomerV1 customerV1) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerV1.Id) { return(BadRequest()); } db.Entry(customerV1).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerV1Exists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <CustomerV1> UpdateCustomerAsync(string correlationId, CustomerV1 customer) { using (Instrument(correlationId, "customers.update_customer")) { return(await _controller.UpdateCustomerAsync(correlationId, customer)); } }
public async Task <CustomerV1> CreateCustomerAsync(string correlationId, CustomerV1 customer) { customer.Id = customer.Id ?? IdGenerator.NextLong(); customer.Gender = customer.Gender ?? CustomerGenderV1.Unknown; return(await _persistence.CreateAsync(correlationId, customer)); }
public async Task <CustomerV1> CreateCustomerAsync(string correlationId, CustomerV1 customer) { _idIdentity++; customer.Id = _idIdentity.ToString(); _customersDict.Add(customer.Id, customer); return(await Task.FromResult(customer)); }
public async Task <CustomerV1> UpdateCustomerAsync(string correlationId, CustomerV1 customer) { if (_customersClient == null) { return(null); } return(await _customersClient.UpdateCustomerAsync(correlationId, customer)); }
public async Task <CustomerV1> UpdateCustomerAsync(string correlationId, CustomerV1 customer) { return(await CallCommandAsync <CustomerV1>( "update_customer", correlationId, new { customer = customer } )); }
public IHttpActionResult GetCustomerV1(int id) { CustomerV1 customerV1 = db.CustomerV1s.Find(id); if (customerV1 == null) { return(NotFound()); } return(Ok(customerV1)); }
public async Task <CustomerV1> DeleteCustomerByIdAsync(string correlationId, string id) { CustomerV1 customer = null; if (_customersDict.TryGetValue(id, out CustomerV1 customerV1)) { _customersDict.Remove(id); customer = customerV1; } return(await Task.FromResult(customer)); }
public IHttpActionResult PostCustomerV1(CustomerV1 customerV1) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CustomerV1s.Add(customerV1); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = customerV1.Id }, customerV1)); }
private static void AssertCustomers(CustomerV1 etalon, CustomerV1 customer) { Assert.NotNull(customer); Assert.Equal(etalon.FirstName, customer.FirstName); Assert.Equal(etalon.LastName, customer.LastName); Assert.Equal(etalon.MiddleName, customer.MiddleName); Assert.Equal(etalon.MobilePhone, customer.MobilePhone); Assert.Equal(etalon.Gender, customer.Gender); Assert.Equal(etalon.Itin, customer.Itin); Assert.Equal(etalon.Passport, customer.Passport); Assert.Equal(etalon.Birthdate, customer.Birthdate); }
public IHttpActionResult DeleteCustomerV1(int id) { CustomerV1 customerV1 = db.CustomerV1s.Find(id); if (customerV1 == null) { return(NotFound()); } db.CustomerV1s.Remove(customerV1); db.SaveChanges(); return(Ok(customerV1)); }
static void Main(string[] args) { string fileNameV1 = @"e:\customer.v1.xml"; string fileNameV2 = @"e:\customer.v2.xml"; CustomerV1 customerV1 = new CustomerV1 { Name = "张三", PhoneNo = "9999-99999999", Address = "江苏省 苏州市 星湖街 328号" }; Serialize <CustomerV1>(customerV1, fileNameV1); CustomerV2 customerV2 = Deserialize <CustomerV2>(fileNameV1); Serialize <CustomerV2>(customerV2, fileNameV2); }
static void Main(string[] args) { string fileName = "customer.xml"; CustomerV1 customerV1 = new CustomerV1 { Name = "张三", PhoneNo = "9999-99999999" }; Console.WriteLine("CustomerV1"); Console.WriteLine("\tName\t: {0}\n\tPhoneNo\t: {1}", customerV1.Name, customerV1.PhoneNo); Serialize <CustomerV1>(customerV1, fileName); CustomerV2 customerV2 = Deserialize <CustomerV2>(fileName); Console.WriteLine("CustomerV2"); Console.WriteLine("\tName\t: {0}\n\tPhoneNo\t: {1}\n\tAddress\t: {2}", customerV2.Name, customerV2.PhoneNo, customerV2.Address ?? "NIL"); }
public async Task <CustomerV1> UpdateCustomerAsync(string correlationId, CustomerV1 customer) { _customersDict[customer.Id] = customer; return(await Task.FromResult(customer)); }
public async Task <CustomerV1> GetCustomerByIdAsync(string correlationId, string id) { CustomerV1 customer = _customersDict.TryGetValue(id, out CustomerV1 customerV1) ? customerV1 : null; return(await Task.FromResult(customer)); }
public async Task <CustomerV1> UpdateCustomerAsync(string correlationId, CustomerV1 customer) { return(await Task.FromResult(new CustomerV1())); }
public async Task <CustomerV1> CreateAsync(string correlationId, CustomerV1 customer) { var result = await CreateAsync(correlationId, FromPublic(customer)); return(ToPublic(result)); }
private static CustomerMongoDbSchema FromPublic(CustomerV1 value) { return(ObjectMapper.MapTo <CustomerMongoDbSchema>(value)); }
public async Task <CustomerV1> UpdateCustomerAsync(string correlationId, CustomerV1 customer) { customer.Gender = customer.Gender ?? CustomerGenderV1.Unknown; return(await _persistence.UpdateAsync(correlationId, customer)); }