/// <inheritdoc/> public async Task UpdateAttribute(AttributeDto input) { var attributeTemplate = await _attributeRepository.GetAsync(input.Id); input.MapTo(attributeTemplate); await attributeManager.UpdateAttributeTempateAsync(attributeTemplate); }
private static void WavesofPulses(object sender, ElapsedEventArgs e) { for (int i = 0; i < 750000; i++) { PulsesRQ request; PulsesRQ pulses = new PulsesRQ(); //var demoProcessedPulses = DemoProcessedPulses(pulses); var demoPruebas = DemoPruebasCLientes(pulses); List <AttributeDto> attributedto = new List <AttributeDto>(); List <string> listAttrb = new List <string>(); listAttrb.Add("attrLong"); listAttrb.Add("newattrLong"); AttributeDto adto = new AttributeDto("bpulse_demo_PruebasClientes", listAttrb); attributedto.Add(adto); List <string> listAttrb2 = new List <string>(); listAttrb2.Add("Long"); listAttrb2.Add("newLong"); AttributeDto adto2 = new AttributeDto("bpulse_bpulse_processedPulses", listAttrb2); attributedto.Add(adto2); request = demoPruebas; BPulseCsharpClient client = new BPulseCsharpClient().GetInstance(); client.SendPulseWithLong(pulses, attributedto); } }
private CreateEntityCommand CreateCreateEntityCommand(string entityName, bool addElement) { var attributeModel = new AttributeDto() { Name = "Id", DataType = EnumDataTypes.String, AllowNull = false, Length = 32 }; var command = new CreateEntityCommand() { Name = entityName, Attributes = new List <AttributeDto>() { attributeModel } }; if (addElement) { var elementEntityCommand = CreateCreateEntityCommand("ElementChild", false); var elementDto = new ElementDto() { Entity = elementEntityCommand, DataType = EnumDataTypes.Object }; command.Elements = new List <ElementDto>() { elementDto }; } return(command); }
private ReportLayoutItemViewModel CreateMeasure(AttributeDto measure) { var item = _reportLayoutItemViewModelFactory(); item.Name = measure.Name; item.Type = AttributeType.Measure; return(item); }
public async Task <ApiResult <List <PriceSelectDto> > > CalculatePrice(AttributeDto dto, CancellationToken cancellationToken) { var attribute = dto.ToEntity(_mapper); var resultDto = await _priceCalculation.CalculatePrice(attribute, dto.CategoryId, cancellationToken); return(resultDto); }
private ReportLayoutItemViewModel CreateDimension(AttributeDto dimension) { var item = _reportLayoutItemViewModelFactory(); item.Name = dimension.Name; item.Type = AttributeType.Dimension; return(item); }
public async Task <ActionResult> UpdateAsync([FromBody] AttributeDto attribute) { _service.Token = await getAccessToken(); await _service.UpdateAsync(_mapper.Map <Attribute>(attribute)); return(Ok()); }
public async Task <ActionResult> InsertAsync([FromBody] AttributeDto attribute) { _service.Token = await getAccessToken(); var inserted = await _service.InsertAsync(_mapper.Map <Attribute>(attribute)); return(CreatedAtAction("GetAttributeById", new { id = inserted.Id }, inserted));; }
// Attribute Mapping public static AttributeDto MapToAttributeDto(Models.Attribute attribute) { var attributeDto = new AttributeDto { AttrId = attribute.AttrId, AttrName = attribute.AttrName, AttrValue = attribute.AttrValue, EmployeeAttributes = new Collection <EmployeeAttributeDto>() // at this point we are ok with new Collection, lateer need to modify }; return(attributeDto); }
public static Models.Attribute MapToAttribute(AttributeDto attributeDto) { var attribute = new Models.Attribute { AttrId = attributeDto.AttrId, AttrName = attributeDto.AttrName, AttrValue = attributeDto.AttrValue, EmployeeAttributes = new Collection <EmployeeAttribute>() }; return(attribute); }
public async Task <ActionResult> PutAttribute(Guid id, [FromBody] AttributeDto attributeDto) { if (id != attributeDto.AttrId) { return(BadRequest()); } //var attribute = MyMapper.MapToAttribute(attributeDto); var attribute = _mapper.Map <Models.Attribute>(attributeDto); await _attributeRepository.Update(attribute); return(NoContent()); }
public async Task <ActionResult <AttributeDto> > PostAttribute([FromBody] AttributeDto attributeDto) // should i exclude Guid from model binder? 8a bgalei error h modelstate? { // ti 8a ginotan stin put ?? if (!ModelState.IsValid) { return(BadRequest()); } //var attribute = MyMapper.MapToAttribute(attributeDto); var attribute = _mapper.Map <Models.Attribute>(attributeDto); await _attributeRepository.Create(attribute); return(CreatedAtAction("GetAttribute", new { id = attributeDto.AttrId }, attributeDto)); }
/// <inheritdoc /> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var result = new AttributeDto(); if (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var key = AttributeKeyCache.Cache.StringToKey(reader.Value.ToString()); var value = reader.ReadAsString(); result = new AttributeDto(key, value); } return(result); }
private List <AttributeDto> GetAttributes() { var list = new List <AttributeDto>(); foreach (DataGridViewRow item in lstAttributes.Rows) { if (item.Cells[0].Value != null && item.Cells[1].Value != null && item.Cells[2].Value != null) { var attribute = new AttributeDto { Name = item.Cells[0].Value.ToString(), FriendlyName = item.Cells[1].Value.ToString(), NameFormat = item.Cells[2].Value.ToString() }; list.Add(attribute); } } return(list); }
public async Task AddAttributeAsync(AttributeDto attribute, CancellationToken cancellationToken = default(CancellationToken)) { var a = new Domain.Core.Attribute { Name = attribute.Name, UnitId = attribute.UnitId }; try { _dbContext.Add(a); await _dbContext.SaveChangesAsync(cancellationToken); } catch (DbUpdateException ex) { throw new InvalidItemException(a, ex); } }
public async Task UpdateAttributeAsync(int attributeId, AttributeDto attribute, CancellationToken cancellationToken = default(CancellationToken)) { var b = new Domain.Core.Attribute { Id = attributeId, Name = attribute.Name, UnitId = attribute.UnitId }; _dbContext.Attach(b).State = EntityState.Modified; try { await _dbContext.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException ex) { throw new ItemNotFoundException(attributeId, "Attribute unit", ex); } catch (DbUpdateException ex) { throw new InvalidItemException(b, ex); } }
public CreateAttributeCommand(AttributeDto attribute) { Attribute = attribute; }
/// <inheritdoc/> public async Task CreateAttribute(AttributeDto input) { var attributeTemplate = input.MapTo <ProductAttribute>(); await attributeManager.CreateAttributeTempateAsync(attributeTemplate); }
public List <IAttribute> FindAllParametricsWithValues(IUser currentUser) { // Find the list of products string url = "ProductService.svc/rest/ListParametricInfo?format=json"; url += addUserUrlDetails(currentUser); var parametricsList = _connectionManager.GetResult <List <StormParametricInfo> >(url); url = "ProductService.svc/rest/ListParametricValues2?format=json"; url += addUserUrlDetails(currentUser); var parametricsValueList = _connectionManager.GetResult <List <StormParametric> >(url); Dictionary <int, StormParametric> valueIds = new Dictionary <int, StormParametric>(); foreach (var value in parametricsValueList) { valueIds[value.Id] = value; } List <IAttribute> list = new List <IAttribute>(); foreach (var parm in parametricsList) { AttributeDto attributeDto = new AttributeDto(); attributeDto.ExternalId = parm.Id.ToString(); attributeDto.Code = parm.Code; attributeDto.Uom = parm.Uom; attributeDto.Name = parm.Name; list.Add(attributeDto); // List value type if (parm.Type == 1) { attributeDto.Values = new List <AttributeValueDto>(); AddParametricChildren(parm.Id, parm.Name, "L" + parm.Id, parm.Type.Value, attributeDto.Values, valueIds, currentUser); } // Multi value type else if (parm.Type == 2) { attributeDto.Values = new List <AttributeValueDto>(); AddParametricChildren(parm.Id, parm.Name, "L" + parm.Id, parm.Type.Value, attributeDto.Values, valueIds, currentUser); } // Boolean else if (parm.ValueType == 4) { attributeDto.Values = new List <AttributeValueDto>(); { AttributeValueDto dto = new AttributeValueDto(); dto.Name = parm.Name + " Ja"; dto.ExternalId = parm.Id.ToString(); dto.Hidden = parm.IsHidden ?? false; dto.QueryCode = "V" + parm.Id + "_1-1"; attributeDto.Values.Add(dto); } { AttributeValueDto dto = new AttributeValueDto(); dto.Name = parm.Name + " Nej"; dto.ExternalId = parm.Id.ToString(); dto.Hidden = parm.IsHidden ?? false; dto.QueryCode = "V" + parm.Id + "_0-0"; attributeDto.Values.Add(dto); } } } return(list); }
public override void AwakeFromNib() { base.AwakeFromNib(); IsUpdated = false; //Events this.BtnAdd.Activated += (object sender, EventArgs e) => { if (string.IsNullOrEmpty(TxtName.StringValue)) { UIErrorHelper.ShowAlert("Name has invalid value", "Alert"); } else if (string.IsNullOrEmpty(TxtIndex.StringValue)) { UIErrorHelper.ShowAlert("Index has invalid value", "Alert"); } else if (ChDefault.StringValue == "1" && DefaultSet && (AttributeConsumerServiceDto != null && !AttributeConsumerServiceDto.IsDefault)) { UIErrorHelper.ShowAlert("Multiple attribute consumer services chosen as default", "Alert"); } else { AttributeConsumerServiceDto = new AttributeConsumerServiceDto { Name = TxtName.StringValue, Index = TxtIndex.IntValue, IsDefault = ChDefault.StringValue == "1", Attributes = (AttributeTableView.DataSource as AttributeDataSource).Entries }; IsUpdated = true; this.Close(); NSApplication.SharedApplication.StopModalWithCode(0); } }; this.BtnAddAttribute.Activated += (object sender, EventArgs e) => { if (string.IsNullOrEmpty(TxtAttributeName.StringValue)) { UIErrorHelper.ShowAlert("Attribute name cannot be empty", "Alert"); return; } if (string.IsNullOrEmpty(TxtFriendlyName.StringValue)) { UIErrorHelper.ShowAlert("Attribute friendly name cannot be empty", "Alert"); return; } if (string.IsNullOrEmpty(TxtNameFormat.StringValue)) { UIErrorHelper.ShowAlert("Attribute name format cannot be empty", "Alert"); return; } var attributeDto = new AttributeDto { Name = TxtAttributeName.StringValue, FriendlyName = TxtFriendlyName.StringValue, NameFormat = TxtNameFormat.StringValue }; TxtAttributeName.StringValue = string.Empty; TxtFriendlyName.StringValue = string.Empty; TxtNameFormat.StringValue = string.Empty; _attributes.Add(attributeDto); AttributeTableView.DataSource = new AttributeDataSource { Entries = _attributes }; AttributeTableView.ReloadData(); }; this.BtnRemoveAttribute.Activated += (object sender, EventArgs e) => { if (AttributeTableView.SelectedRow > -1) { _attributes.RemoveAt((int)AttributeTableView.SelectedRow); AttributeTableView.DataSource = new AttributeDataSource { Entries = _attributes }; AttributeTableView.ReloadData(); } }; this.BtnClose.Activated += (object sender, EventArgs e) => { this.Close(); NSApplication.SharedApplication.StopModalWithCode(0); }; if (AttributeConsumerServiceDto != null) { TxtName.StringValue = AttributeConsumerServiceDto.Name; _attributes = AttributeConsumerServiceDto.Attributes; ChDefault.StringValue = AttributeConsumerServiceDto.IsDefault ? "1" : "0"; TxtIndex.IntValue = AttributeConsumerServiceDto.Index; } InitializeAttributes(); }
public Task Post([FromBody] AttributeDto attribute) { return(_attributesService.AddAttributeAsync(attribute, HttpContext.RequestAborted)); }
public async Task <IActionResult> CreateAttribute([FromBody] AttributeDto dto) { var result = await _mediator.Send(new CreateAttributeCommand(dto)); return(result.StatusCode == 200 ? Ok(result.Result) : StatusCode(result.StatusCode, result.Errors)); }
public Task Put(int attributeId, [FromBody] AttributeDto attribute) { return(_attributesService.UpdateAttributeAsync(attributeId, attribute, HttpContext.RequestAborted)); }