Esempio n. 1
0
 public void Put(string id, [FromBody] CreateAttributeDto value)
 {
     try {
         AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
         _attributeApplicationService.When(value as ICreateAttribute);
     } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
 }
Esempio n. 2
0
        public static DAL.Models.Attribute AttributeToDbo(CreateAttributeDto createAttributeDto, AttributeGroup attributeGroup)
        {
            var model = new DAL.Models.Attribute()
            {
                Name             = createAttributeDto.AttributeName,
                Value            = EnumHelper.GetValueType(createAttributeDto.ValueTypeId),
                AttributeGroupId = createAttributeDto.AttributeGroupId,
                AttributeGroup   = attributeGroup,
                CreationDate     = DateTime.Now
            };

            return(model);
        }
Esempio n. 3
0
        public HttpResponseMessage Post([FromBody] CreateAttributeDto value)
        {
            try {
                if (value.AttributeId == default(string))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "Attribute");
                }
                _attributeApplicationService.When(value as ICreateAttribute);
                var idObj = value.AttributeId;

                return(Request.CreateResponse <string>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
Esempio n. 4
0
        public async Task WhenAsync(CreateAttributeDto c)
        {
            var idObj         = (c as ICreateAttribute).AttributeId;
            var uriParameters = new AttributeUriParameters();

            uriParameters.Id = idObj;

            var req = new AttributePutRequest(uriParameters, (CreateAttributeDto)c);

            var resp = await _ramlClient.Attribute.Put(req);

            AttributeProxyUtils.ThrowOnHttpResponseError(resp);
        }
Esempio n. 5
0
        public HttpStatusCode CreateAttribute(CreateAttributeDto createAttributeDto)
        {
            var response = _attributeRepository.CreateAttribute(createAttributeDto);

            switch (response)
            {
            case HttpStatusCode.OK:
                return(HttpStatusCode.OK);

            case HttpStatusCode.InternalServerError:
                return(HttpStatusCode.InternalServerError);

            default:
                return(HttpStatusCode.NotFound);
            }
        }
Esempio n. 6
0
        public HttpStatusCode CreateAttribute(CreateAttributeDto createAttributeDto)
        {
            AttributeGroup attributeGroup = _ctx.AttributeGroups
                                            .FirstOrDefault(f => f.Id == createAttributeDto.AttributeGroupId);

            var model = AttributeFactory.AttributeToDbo(createAttributeDto, attributeGroup);

            try
            {
                _ctx.Attributes.Add(model);
                _ctx.SaveChanges();

                return(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                return(HttpStatusCode.InternalServerError);
            }
        }
Esempio n. 7
0
 public void When(CreateAttributeDto c)
 {
     WhenAsync(c).GetAwaiter().GetResult();
 }