public virtual IHttpActionResult PutCustomer(Guid contactId, [FromBody] Contact contact) { Logger.LogPut("PutCustomer", Request, new [] { contactId.ToString() }); var existingContact = CustomerContext.Current.GetContactById(contactId); if (existingContact == null) { return(NotFound()); } try { existingContact.FirstName = contact.FirstName; existingContact.LastName = contact.LastName; existingContact.Email = contact.Email; existingContact.UserId = "String:" + contact.Email; // The UserId needs to be set in the format "String:{email}". Else a duplicate CustomerContact will be created later on. existingContact.RegistrationSource = contact.RegistrationSource; if (contact.Addresses != null) { foreach (var address in contact.Addresses) { CustomerMappings.CreateOrUpdateCustomerAddress(existingContact, address); } } existingContact.SaveChanges(); // default address } catch (Exception exception) { Logger.Error(exception.Message, exception); return(InternalServerError(exception)); } return(Ok()); }
public virtual IHttpActionResult PutCart([FromBody] Cart cart) { Logger.LogPut("PutCart", Request); try { _orderRepository.Save(cart); } catch (Exception exception) { Logger.Error(exception.Message, exception); return(InternalServerError(exception)); } return(Ok()); }