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); } }
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); }
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); } }
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); }
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); } }
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); } }
public void When(CreateAttributeDto c) { WhenAsync(c).GetAwaiter().GetResult(); }