Esempio n. 1
0
        public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeletePartyDto value)
        {
            var idObj = id;

            if (value.PartyId == null)
            {
                value.PartyId = idObj;
            }
            else if (!((ICreateOrMergePatchOrDeleteParty)value).PartyId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.PartyId);
            }
        }
Esempio n. 2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeletePartyDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    PartiesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _partyApplicationService.When(value as IMergePatchParty);
                    return;
                }
                // ///////////////////////////////

                PartiesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _partyApplicationService.When(value as ICreateParty);
            } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }