private Customer AddOrUpdateCustomer(Customer toAddOrUpdate) { Customer toReturn = null; try { using (var msSql = DBController.GetDBConnection()) { DynamicParameters p = new DynamicParameters(); p.Add("CustomerID", toAddOrUpdate.CustomerID); p.Add("FirstName", toAddOrUpdate.FirstName); p.Add("LastName", toAddOrUpdate.LastName); p.Add("MiddleName", toAddOrUpdate.MiddleName); p.Add("EmailAddress", toAddOrUpdate.EmailAddress); p.Add("Street", toAddOrUpdate.Street); p.Add("Housenumber", toAddOrUpdate.Housenumber); p.Add("PostalCode", toAddOrUpdate.PostalCode); p.Add("City", toAddOrUpdate.City); toReturn = msSql.Query<Customer>("up_AddOrUpdateCustomer", param: p, commandType: CommandType.StoredProcedure).FirstOrDefault(); } } catch (Exception ex) { logger.Error("Error retrieving DB customer", ex); } return toReturn; }
public bool PutUpdateCustomer(Customer toUpdate) { return AddOrUpdateCustomer(toUpdate) != null; }
public Customer PostAddCustomer(Customer toAdd) { return AddOrUpdateCustomer(toAdd); }
public async Task<Customer> AddCustomer(Customer toAdd) { Customer toReturn = null; try { using (var client = new HttpClient()) { SetupClient(client); HttpResponseMessage response = await client.PostAsJsonAsync<Customer>("api/customers", toAdd); if (response.IsSuccessStatusCode) toReturn = await response.Content.ReadAsAsync<Customer>(); } } catch (Exception ex) { logger.Error(string.Format("Error adding Customer"), ex); } return toReturn; }
public async Task<bool> UpdateCustomer(Customer toUpdate) { bool success = false; try { using (var client = new HttpClient()) { SetupClient(client); HttpResponseMessage response = await client.PutAsJsonAsync<Customer>("api/customers", toUpdate); success = response.IsSuccessStatusCode; } } catch (Exception ex) { logger.Error(string.Format("Error loading UpdateCustomer [{0}]", toUpdate.CustomerID), ex); } return success; }
public bool SendMessage(Customer customer, string message) { throw new NotImplementedException(); }
public CartViewModel(IWebservice webService, IEnumerable<CartItem> currentCart, Customer currentCustomer) : base(webService) { this.MyCart = new ObservableCollection<CartItem>(currentCart); this.currentCustomer = currentCustomer; }