Ejemplo n.º 1
0
        public HttpResponseMessage Post(string applicationReference, string customerReference, Email email)
        {
            Check.If(applicationReference).IsNotNullOrEmpty();
            Check.If(customerReference).IsNotNullOrEmpty();
            Check.If(email).IsNotNull();

            var result = _emailService.CreateCustomerEmail(applicationReference, customerReference,
                Mapper.Map<Core.Objects.Email>(email));

            if (result == null)
            {
                return new HttpResponseMessage {StatusCode = HttpStatusCode.InternalServerError};
            }

            var response = new HttpResponseMessage {StatusCode = HttpStatusCode.Created};

            response.Headers.Location =
                new Uri(Url.Link("GetEmailForCustomer",
                    new {applicationReference, customerReference, emailAddressReference = result}));

            return response;
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Put(string applicationReference, string customerReference,
            string emailAddressReference, Email email)
        {
            Check.If(applicationReference).IsNotNullOrEmpty();
            Check.If(customerReference).IsNotNullOrEmpty();
            Check.If(emailAddressReference).IsNotNullOrEmpty();
            Check.If(email).IsNotNull();

            var result = _emailService.UpdateCustomerEmail(applicationReference, customerReference,
                emailAddressReference, Mapper.Map<Core.Objects.Email>(email));

            return result
                ? new HttpResponseMessage {StatusCode = HttpStatusCode.OK}
                : new HttpResponseMessage {StatusCode = HttpStatusCode.InternalServerError};
        }