public IHttpActionResult UpdateAttribute(EAV.Store.IStoreAttribute attribute) { try { attributeClient.UpdateAttribute(attribute); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void UpdateAttribute() { var dbAttribute = SelectRandomItem(this.DbContext.Attributes); string oldName = dbAttribute.Name; string oldDataName = dbAttribute.Data_Name; string oldDisplayText = dbAttribute.Display_Text; bool oldIsKey = dbAttribute.Is_Key; int oldSequence = dbAttribute.Sequence; bool oldVariableUnits = dbAttribute.Variable_Units.GetValueOrDefault(); EAV.Store.Clients.IAttributeStoreClient client = factory.Create <EAV.Store.Clients.IAttributeStoreClient>(); var attribute = (EAVStoreLibrary.StoreAttribute)dbAttribute; attribute.Name = oldName.Flip(); attribute.DataName = oldDataName.Flip(); attribute.DisplayText = oldDisplayText.Flip(); attribute.IsKey = !oldIsKey; attribute.Sequence = oldSequence != 0 ? -oldSequence : -1; attribute.VariableUnits = !oldVariableUnits; client.UpdateAttribute(attribute); ResetDatabaseContext(); dbAttribute = this.dbContext.Attributes.Single(it => it.Attribute_ID == attribute.AttributeID); Assert.AreEqual(attribute.Name, dbAttribute.Name); Assert.AreNotEqual(oldName, dbAttribute.Name); Assert.AreEqual(attribute.DataName, dbAttribute.Data_Name); Assert.AreNotEqual(oldDataName, dbAttribute.Data_Name); Assert.AreEqual(attribute.DisplayText, dbAttribute.Display_Text); Assert.AreNotEqual(oldDisplayText, dbAttribute.Display_Text); Assert.AreEqual(attribute.IsKey, dbAttribute.Is_Key); Assert.AreNotEqual(oldIsKey, dbAttribute.Is_Key); Assert.AreEqual(attribute.Sequence, dbAttribute.Sequence); Assert.AreNotEqual(oldSequence, dbAttribute.Sequence); Assert.AreEqual(attribute.VariableUnits, dbAttribute.Variable_Units.GetValueOrDefault()); Assert.AreNotEqual(oldVariableUnits, dbAttribute.Variable_Units.GetValueOrDefault()); }