public ItemTypeAggregate AddChild(String Code, String Descr, int MinLen, int MaxLen, String InvAcc , Decimal OverQty, Boolean IsFgRef, Boolean IsVirtual, Boolean IsLotManaged , Decimal OverRate, String PreFix, Decimal MinScpRate, Decimal MaxScpRate) { ItemTypeEntity ItemType = new ItemTypeEntity() { Code = Code, Descr = Descr, ItemNumMinLength = MinLen, ItemNumMaxLength = MaxLen, AttribType = this.ItemType.AttribType, InvAcc = InvAcc, IsFgRef = IsFgRef, IsVirtual = IsVirtual, ItemGroup = this.ItemType.ItemGroup, IsLotManaged = IsLotManaged, MaxScpRate = MaxScpRate, MinScpRate = MinScpRate, OverQty = OverQty, OverRate = OverRate, ParentID = this.Code, PreFix = PreFix, State = Entity.EntityState.Added }; return(new ItemTypeAggregate(ItemType.Code, ItemType)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] ItemTypeEntity itemTypeEntity) { if (id != itemTypeEntity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(itemTypeEntity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemTypeEntityExists(itemTypeEntity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(itemTypeEntity)); }
private void SaveChange(ItemTypeEntity itemType) { ItemType entity = null; switch (itemType.State) { case Domain.Entity.EntityState.Detached: _dbContext.Set <ItemType>().Add(Mapper.Map <ItemTypeEntity, ItemType>(itemType)); break; case Domain.Entity.EntityState.Added: _dbContext.Set <ItemType>().Add(Mapper.Map <ItemTypeEntity, ItemType>(itemType)); break; case Domain.Entity.EntityState.Deleted: entity = _dbContext.Set <ItemType>().FirstOrDefault(p => p.CODE.Equals(itemType.Code)); if (entity == null) { new Exception("次类【" + itemType.Code + "】不存在,删除失败!"); } Mapper.Map <ItemTypeEntity, ItemType>(itemType, entity); _dbContext.Set <ItemType>().Add(Mapper.Map <ItemTypeEntity, ItemType>(itemType)); break; } }
/// <summary> setups the sync logic for member _itemType</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncItemType(IEntity2 relatedEntity) { if (_itemType != relatedEntity) { DesetupSyncItemType(true, true); _itemType = (ItemTypeEntity)relatedEntity; base.PerformSetupSyncRelatedEntity(_itemType, new PropertyChangedEventHandler(OnItemTypePropertyChanged), "ItemType", ItemDetailsEntity.Relations.ItemTypeEntityUsingItemTypeId, true, new string[] { }); } }
/// <summary> /// Initializes a new instance of the <see cref="Item"/> class. /// </summary> /// <param name="type">The type of this item.</param> public Item(ItemTypeEntity type) { type.ThrowIfNull(nameof(type)); this.Type = type; // make a copy of the type we are based on... this.Attributes = new Dictionary <ItemAttribute, IConvertible>(this.Type.DefaultAttributes.Select(kvp => KeyValuePair.Create((ItemAttribute)kvp.Key, kvp.Value))); this.InitializeExpirationTime(); }
public async Task <IActionResult> Create([Bind("Id,Name")] ItemTypeEntity itemTypeEntity) { if (ModelState.IsValid) { _context.Add(itemTypeEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(itemTypeEntity)); }
/// <summary> Initializes the class members</summary> protected virtual void InitClassMembers() { _itemUserAccess = null; _messageDetails = null; _messageDetailsCollectionViaMessageDetails = null; _itemType = null; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
protected ItemDetailsEntity(SerializationInfo info, StreamingContext context) : base(info, context) { if (SerializationHelper.Optimization != SerializationOptimization.Fast) { _itemUserAccess = (EntityCollection <ItemUserAccessEntity>)info.GetValue("_itemUserAccess", typeof(EntityCollection <ItemUserAccessEntity>)); _messageDetails = (EntityCollection <MessageDetailsEntity>)info.GetValue("_messageDetails", typeof(EntityCollection <MessageDetailsEntity>)); _messageDetailsCollectionViaMessageDetails = (EntityCollection <MessageDetailsEntity>)info.GetValue("_messageDetailsCollectionViaMessageDetails", typeof(EntityCollection <MessageDetailsEntity>)); _itemType = (ItemTypeEntity)info.GetValue("_itemType", typeof(ItemTypeEntity)); if (_itemType != null) { _itemType.AfterSave += new EventHandler(OnEntityAfterSave); } base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance()); } // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
public void UpdateItemTypeEntity(ItemTypeEntity itemType) { ItemType = itemType;; }
public ItemTypeAggregate(String Code, ItemTypeEntity ItemType) { this.Code = Code; this.ItemType = ItemType; }
/// <summary> /// Attempts to load the item catalog. /// </summary> /// <returns>The catalog, containing a mapping of loaded id to the item types.</returns> public IDictionary <ushort, IItemTypeEntity> LoadTypes() { var itemDictionary = new Dictionary <ushort, IItemTypeEntity>(); var objectsFilePath = Path.Combine(Environment.CurrentDirectory, this.LoaderOptions.FilePath); var currentType = new ItemTypeEntity(); foreach (var readLine in File.ReadLines(objectsFilePath)) { if (readLine == null) { continue; } var inLine = readLine.Split(new[] { CommentSymbol }, 2).FirstOrDefault(); // ignore comments and empty lines. if (string.IsNullOrWhiteSpace(inLine)) { // wrap up the current ItemType and add it if it has enough properties set: if (currentType.TypeId == 0 || string.IsNullOrWhiteSpace(currentType.Name)) { continue; } currentType.LockChanges(); itemDictionary.Add(currentType.TypeId, currentType); currentType = new ItemTypeEntity(); continue; } var data = inLine.Split(new[] { PropertyValueSeparator }, 2); if (data.Length != 2) { throw new InvalidDataException($"Malformed line [{inLine}] in objects file: [{objectsFilePath}]"); } var propName = data[0].ToLower().Trim(); var propData = data[1].Trim(); switch (propName) { case "typeid": currentType.TypeId = Convert.ToUInt16(propData); break; case "name": currentType.Name = propData.Substring(Math.Min(1, propData.Length), Math.Max(0, propData.Length - 2)); break; case "description": currentType.Description = propData; break; case "flags": foreach (var element in CipFileParser.Parse(propData)) { var flagName = element.Attributes.First().Name; if (Enum.TryParse(flagName, out CipItemFlag flagMatch)) { if (flagMatch.ToItemFlag() is ItemFlag itemflag) { currentType.SetItemFlag(itemflag); } continue; } this.Logger.Warning($"Unknown flag [{flagName}] found on item with TypeID [{currentType.TypeId}]."); } break; case "attributes": foreach (var attrStr in propData.Substring(Math.Min(1, propData.Length), Math.Max(0, propData.Length - 2)).Split(',')) { var attrPair = attrStr.Split('='); if (attrPair.Length != 2) { this.Logger.Error($"Invalid attribute {attrStr}."); continue; } var attributeName = attrPair[0]; var attributeValue = Convert.ToInt32(attrPair[1]); if (Enum.TryParse(attributeName, out CipItemAttribute cipAttribute)) { if (cipAttribute.ToItemAttribute() is ItemAttribute itemAttribute) { currentType.SetAttribute(itemAttribute, attributeValue); } continue; } this.Logger.Warning($"Attempted to set an unknown item attribute [{attributeName}]."); } break; } } // wrap up the last ItemType and add it if it has enough properties set: if (currentType.TypeId != 0 && !string.IsNullOrWhiteSpace(currentType.Name)) { currentType.LockChanges(); itemDictionary.Add(currentType.TypeId, currentType); } return(itemDictionary); }
/// <summary> /// Initializes a new instance of the <see cref="ContainerItem"/> class. /// </summary> /// <param name="type">The type of this item.</param> public ContainerItem(ItemTypeEntity type) : base(type) { this.Content = new List <IItem>(); }
public ItemTypeAggregate(String Code, ItemTypeEntity ItemType, ICollection <ItemTypeEntity> Childs) { this.Code = Code; this.ItemType = ItemType; this.Childs = Childs; }
/// <summary> Removes the sync logic for member _itemType</summary> /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param> /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param> private void DesetupSyncItemType(bool signalRelatedEntity, bool resetFKFields) { base.PerformDesetupSyncRelatedEntity(_itemType, new PropertyChangedEventHandler(OnItemTypePropertyChanged), "ItemType", ItemDetailsEntity.Relations.ItemTypeEntityUsingItemTypeId, true, signalRelatedEntity, "ItemDetails", resetFKFields, new int[] { (int)ItemDetailsFieldIndex.ItemTypeId }); _itemType = null; }