Example #1
0
        public IRubiksCube Create(int cubesPerRow)
        {
            var root = new GameObject(nameof(RubiksCube));

            pieceFactory.CubesPerRow = cubesPerRow;
            pieceFactory.Parent      = root;

            var pieces = new List <IPiece>(cubesPerRow * cubesPerRow * cubesPerRow);

            for (var z = 0; z < cubesPerRow; ++z)
            {
                for (var y = 0; y < cubesPerRow; ++y)
                {
                    for (var x = 0; x < cubesPerRow; ++x)
                    {
                        pieces.Add(pieceFactory.Create(x, y, z));
                    }
                }
            }

            return(new RubiksCube(root, pieces, cubesPerRow));
        }
Example #2
0
        public void Execute(CreatePieceModel model)
        {
            Country countryOfOrigin = null;

            if (model.CountryOfOriginId.HasValue)
            {
                countryOfOrigin = repository.GetCountry(model.CountryOfOriginId.Value);
            }

            var museum            = repository.GetMuseum(model.MuseumId);
            var unitOfMeasure     = repository.GetUnitOfMeasure(model.UnitOfMeasureId);
            var artist            = GetArtist(model);
            var medium            = GetMedium(model);
            var genre             = GetGenre(model);
            var subgenre          = GetSubgenre(model);
            var subjectMatter     = GetSubjectMatter(model);
            var acquisition       = GetAcquisition(model);
            var currentLocation   = GetCurrentLocation(model);
            var permanentLocation = GetPermanentLocation(model);
            var collection        = GetCollection(model);
            var timeStamp         = dateService.GetCurrentServerTime();

            var piece = pieceFactory.Create(
                ++museum.RecordCount,
                model.Title,
                model.AccessionNumber,
                model.CreationDay,
                model.CreationMonth,
                model.CreationYear,
                countryOfOrigin,
                model.StateOfOrigin,
                model.CityOfOrigin,
                model.Height,
                model.Width,
                model.Depth,
                unitOfMeasure,
                model.EstimatedValue,
                model.Subject,
                model.CopyrightYear,
                model.CopyrightOwner,
                model.InsurancePolicyNumber,
                model.InsuranceExpirationDate,
                model.InsuranceAmount,
                model.InsuranceCarrier,
                model.IsFramed,
                model.IsArchived,
                artist,
                medium,
                genre,
                subgenre,
                subjectMatter,
                acquisition,
                currentLocation,
                permanentLocation,
                collection,
                model.LastModifiedByUserId,
                timeStamp,
                model.MuseumId);

            repository.AddPiece(piece);

            unitOfWork.Save();
        }