Exemple #1
0
        public virtual IHttpActionResult PostOrganization([FromBody] Organization organization)
        {
            Logger.LogPost("PostOrganization", Request);

            try
            {
                var newOrganization = Mediachase.Commerce.Customers.Organization.CreateInstance();
                newOrganization.PrimaryKeyId = new PrimaryKeyId(organization.PrimaryKeyId);
                //newOrganization.Addresses
                newOrganization.OrgCustomerGroup = organization.OrgCustomerGroup;
                newOrganization.OrganizationType = organization.OrganizationType;
                //newOrganization.Contacts =

                newOrganization.SaveChanges();

                organization = newOrganization.ConvertToOrganization();
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(InternalServerError(exception));
            }

            return(Ok(organization));
        }
Exemple #2
0
        public void post_creates_new_organization()
        {
            var model = new Organization
            {
                PrimaryKeyId = Guid.NewGuid()
            };

            PostOrganization(model);
            DeleteOrganization(model.PrimaryKeyId.ToString());
        }
Exemple #3
0
        private void PutOrganization(Organization model)
        {
            var json = JsonConvert.SerializeObject(model);

            var response = Client.PutAsync($"/episerverapi/commerce/customer/organization", new StringContent(json, Encoding.UTF8, "application/json")).Result;

            var message = response.Content.ReadAsStringAsync().Result;

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception($"Put failed! Status: {response.StatusCode}. Message: {message}");
            }
        }