/// <inheritdoc/> public void CreatePackColour(IPackColour packColour) { PackColourDto packColourDto = PackColourDto.ToDto(packColour); this.Context.PackColours.Add(packColourDto); int count = this.Context.SaveChanges(); if (count != 1) { throw new ApplicationException($"Unexpectedly created {count} rows"); } }
/// <summary> /// Converts domain object to DTO. /// </summary> /// <param name="packColour">The pack colour.</param> /// <returns>Pack Colour DTO.</returns> public static PackColourDto ToDto(IPackColour packColour) { if (packColour == null) { throw new ArgumentNullException(nameof(packColour)); } return(new PackColourDto( id: packColour.Id, code: packColour.Code, colour: packColour.Colour)); }
/// <summary> /// Initializes a new instance of the <see cref="Pack"/> class. /// </summary> /// <param name="id">Pack Id.</param> /// <param name="packColour">Pack Colour.</param> /// <param name="set">Set.</param> /// <param name="enteredService">Date the Pack Entered Service.</param> /// <param name="boardNumber">Board Number.</param> public Pack( Guid id, IPackColour packColour, ISet set, DateTime enteredService, int boardNumber) { this.Id = id; this.PackColour = packColour ?? throw new ArgumentNullException(nameof(packColour)); this.Set = set ?? throw new ArgumentNullException(nameof(set)); this.EnteredService = enteredService; if (boardNumber < 1 || boardNumber > MaxBoardNumber) { throw new ArgumentOutOfRangeException(nameof(boardNumber)); } this.BoardNumber = boardNumber; }