public void AssemblerCorrectlyReadsInventoryItemDto()
        {
            var eventAreaDto = new EventAreaDto() { EventName = Constants.EventAreas.POLE_VAULT };
            var poleVaulter = new AthleteDto() { Nickname = "poleVaulter", FirstName = "Pole", LastName = "Vaulter1", Gender = 'M', Status = "Current" };
            var modelDto = new ModelDto();
            var model = new Model();
            var inventoryItemDto = new InventoryItemDto()
                {
                    SerialNumber = 1,
                    ModelDto = modelDto,
                    SizeM = 9,
                    SizeW = 11,
                    Width = "N",
                    RequestName = "request1",
                    EventAreaAssignmentDto = eventAreaDto,
                    Status = "Requested",
                };
            var historyDto = new InventoryMovementDto() { EventType = new InventoryEventTypeDto() { EventType = Constants.InventoryEventTypes.ORDER } };

            inventoryItemDto.MovementHistory.Add(historyDto);

            _mockModelAssembler.Setup(x => x.ReadDto(modelDto)).Returns(model);
            _mockAthleteRepository.Setup(x => x.GetByNickname(It.IsAny<String>())).Returns(new Athlete());
            _mockInventoryRepository.Setup(x => x.GetBySerialNumber(inventoryItemDto.SerialNumber));
            _mockInventoryMovementAssembler.Setup(x => x.ReadDto(historyDto)).Returns(new InventoryMovement());
            _mockEventAreaAssembler.Setup(x => x.ReadDto(eventAreaDto)).Returns(new EventArea() { EventName = eventAreaDto.EventName });

            var inventoryItem = _assembler.ReadDto(inventoryItemDto);

            _mockInventoryRepository.VerifyAll();
            _mockModelAssembler.VerifyAll();
            _mockAthleteRepository.VerifyAll();
            _mockInventoryMovementAssembler.VerifyAll();
            _mockEventAreaAssembler.VerifyAll();
        }
        public InventoryItemDto WriteDto(InventoryItem inventoryItem)
        {
            if (inventoryItem == null)
                throw new ArgumentNullException();

            var inventoryMovementAssembler = ObjectFactory.GetInstance<IInventoryMovementAssembler>();
            var inventoryItemDto = new InventoryItemDto();

            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
            inventoryItemDto.ModelDto = ObjectFactory.GetInstance<IModelAssembler>().WriteDto(inventoryItem.Model);
            inventoryItemDto.SizeM = inventoryItem.SizeM;
            inventoryItemDto.SizeW = inventoryItem.SizeW;
            inventoryItemDto.Width = inventoryItem.Width;
            inventoryItemDto.RequestName = inventoryItem.RequestName;
            inventoryItemDto.Status = inventoryItem.Status;
            inventoryItemDto.StatusLastChanged = inventoryItem.StatusLastChanged;
            inventoryItemDto.EventAreaAssignmentDto = ObjectFactory.GetInstance<IEventAreaAssembler>().WriteDto(inventoryItem.EventAreaAssignment);
            inventoryItemDto.AthleteNickname = inventoryItem.Athlete != null ? inventoryItem.Athlete.Nickname : null;

            var receivedEvent = inventoryItem.MovementHistory.FirstOrDefault(i => i.EventType.EventType == Constants.InventoryEventTypes.RECEIPT_FROM_VENDOR);
            if (receivedEvent != null)
                inventoryItemDto.ReceivedOn = receivedEvent.EventDate.ToShortDateString();

            foreach (var movement in inventoryItem.MovementHistory)
                inventoryItemDto.MovementHistory.Add(inventoryMovementAssembler.WriteDto(movement));

            return inventoryItemDto;
        }
        public void CanGetAllEventParticipants()
        {
            var poleVaulter = new AthleteDto() { Nickname = "poleVaulter", FirstName = "Pole", LastName = "Vaulter1", Gender = 'M', Status = "Current" };
            var poleVaultingSprinter = new AthleteDto() { Nickname = "poleVaulingSprinter", FirstName = "PoleVaulting", LastName = "Sprinter", Gender = 'F', Status = "Future" };
            var sprinter = new AthleteDto() { Nickname = "sprinter", FirstName = "Sprint", LastName = "er", Gender = 'M', Status = "Past" };
            var poleVault = new EventAreaDto() { EventName = "PoleVault" };
            var sprints = new EventAreaDto() { EventName = "Sprints" };
            var modelDto = new ModelDto() { ModelNumber = "1234", ModelName = "name", Type = "runner", Color = "white", Price = 105, IsDiscontinued = false };
            var shoe1 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", StatusLastChanged = DateTime.Now };
            var shoe2 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", StatusLastChanged = DateTime.Now };
            var shoe3 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", StatusLastChanged = DateTime.Now };

            poleVaulter.EventParticipation.Add(poleVault);
            poleVaultingSprinter.EventParticipation.Add(poleVault);
            poleVaultingSprinter.EventParticipation.Add(sprints);
            sprinter.EventParticipation.Add(sprints);
            poleVaulter.Inventory.Add(shoe1);
            poleVaulter.Inventory.Add(shoe2);
            poleVaultingSprinter.Inventory.Add(shoe3);

            CoreAthleteService.SaveAthlete(poleVaulter);
            CoreAthleteService.SaveAthlete(poleVaultingSprinter);
            CoreAthleteService.SaveAthlete(sprinter);

            var poleVaultersList = CoreAthleteService.GetAllAthletesForEventArea("PoleVault");

            Assert.IsNotNull(poleVaultersList);
            Assert.AreEqual(2, poleVaultersList.Count);
            Assert.IsNotNull(poleVaultersList.ToList().First(x => x.Nickname == poleVaulter.Nickname));
            Assert.IsNotNull(poleVaultersList.ToList().First(x => x.Nickname == poleVaultingSprinter.Nickname));
            Assert.IsNull(poleVaultersList.ToList().FirstOrDefault(x => x.Nickname == sprinter.Nickname));
        }
        public void Order()
        {
            var oldStatusLastChanged = DateTime.Now.ToBinary();
            _inventoryItemDto.Status = Constants.Inventory.REQUESTED;
            _inventoryItemDto = InventoryService.Order(_inventoryItemDto, String.Empty);

            var fromDb = _inventoryItemRepository.GetBySerialNumber(_inventoryItem.SerialNumber);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(Constants.Inventory.ORDERED, fromDb.Status);
            Assert.AreEqual(Constants.Inventory.ORDERED, _inventoryItemDto.Status);
            Assert.IsTrue(fromDb.StatusLastChanged.ToBinary() > oldStatusLastChanged);
        }
        public void Recall()
        {
            var oldStatusLastChanged = DateTime.Now.ToBinary();
            _inventoryItemDto.Status = Constants.Inventory.IN_STOCK;
            _inventoryItemDto = InventoryService.Recall(_inventoryItemDto, "Some message");

            var fromDb = _inventoryItemRepository.GetBySerialNumber(_inventoryItemDto.SerialNumber);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(Constants.Inventory.RECALLED, fromDb.Status);
            Assert.AreEqual(Constants.Inventory.RECALLED, _inventoryItemDto.Status);
            Assert.IsTrue(fromDb.StatusLastChanged.ToBinary() > oldStatusLastChanged);
        }
        public void Distribute()
        {
            var oldStatusLastChanged = DateTime.Now.ToBinary();
            _inventoryItemDto.Status = Constants.Inventory.IN_STOCK;

            _inventoryItemDto = InventoryService.Distribute(_inventoryItemDto, String.Empty);

            var fromDb = _inventoryItemRepository.GetBySerialNumber(_inventoryItemDto.SerialNumber);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(Constants.Inventory.DISTRIBUTED, fromDb.Status);
            Assert.AreEqual(Constants.Inventory.DISTRIBUTED, _inventoryItemDto.Status);
            Assert.IsTrue(fromDb.StatusLastChanged.ToBinary() > oldStatusLastChanged);
        }
 public InventoryItemDto Recall(InventoryItemDto inventoryItemDto, String description)
 {
     try
     {
         return InventoryService.Recall(inventoryItemDto, description);
     }
     catch (InvalidOperationException e)
     {
         throw new FaultException(
             new FaultReason(e.Message),
             new FaultCode(e.Message)
         );
     }
 }
 public InventoryItemDto AssignInventoryItemToAthlete(InventoryItemDto inventoryItemDto, AthleteDto athleteDto, String description)
 {
     try
     {
         return InventoryService.AssignInventoryItemToAthlete(inventoryItemDto, athleteDto, description);
     }
     catch (InvalidOperationException e)
     {
         throw new FaultException(
             new FaultReason(e.Message),
             new FaultCode(e.Message)
         );
     }
 }
        public void AssemblerCorrectlyReadsAthleteDto()
        {
            var athleteDto = new AthleteDto();
            athleteDto.Id = 123456;
            athleteDto.Nickname = "TestNickname";
            athleteDto.FirstName = "TestFirstName";
            athleteDto.LastName = "TestLastName";
            athleteDto.Gender = 'M';
            athleteDto.TrainerSizeM = 9.5;
            athleteDto.SpikeSizeM = 8.5;
            athleteDto.Notes = "Some test notes";
            athleteDto.Status = "Current";

            var eventAreaDto = new EventAreaDto();
            eventAreaDto.EventName = Constants.EventAreas.POLE_VAULT;
            eventAreaDto.IsParticipant = true;

            var modelDto = new ModelDto();
            modelDto.ModelNumber = "1234";
            modelDto.ModelName = "model name";
            modelDto.Type = "model type";
            modelDto.Price = 105.00;
            modelDto.Color = "white";
            modelDto.IsDiscontinued = false;

            var inventoryItemDto = new InventoryItemDto();
            inventoryItemDto.SerialNumber = 1;
            inventoryItemDto.ModelDto = modelDto;
            inventoryItemDto.SizeM = 9;
            inventoryItemDto.SizeW = 11;
            inventoryItemDto.Width = "N";
            inventoryItemDto.RequestName = "request1";
            inventoryItemDto.Status = "Requested";
            inventoryItemDto.StatusLastChanged = new DateTime(2012, 10, 31, 12, 0, 0);

            athleteDto.EventParticipation.Add(eventAreaDto);
            athleteDto.Inventory.Add(inventoryItemDto);

            _mockAthleteRepository.Setup(x => x.GetByNickname(athleteDto.Nickname));
            _mockEventAreaAssembler.Setup(x => x.ReadDto(eventAreaDto)).Returns(new EventArea());
            _mockInventoryItemAssembler.Setup(x => x.ReadDto(inventoryItemDto)).Returns(new InventoryItem());

            var athleteFromDb = _assembler.ReadDto(athleteDto);

            _mockAthleteRepository.VerifyAll();
            _mockEventAreaAssembler.VerifyAll();
            _mockInventoryItemAssembler.VerifyAll();
        }
        public static void Recall(InventoryItemDto inventoryItemDto, String description)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

            inventoryItemRepository.Recall(inventoryItem);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.RECALL_FROM_ATHLETE, description));

            inventoryItemDto.Status = Constants.Inventory.RECALLED;
            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
        }
        public static InventoryItemDto AssignInventoryItemToAthlete(InventoryItemDto inventoryItemDto, AthleteDto athleteDto, String description)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            var athlete = athleteAssembler.ReadDto(athleteDto);

            inventoryItemRepository.Save(inventoryItem);

            return ObjectFactory.GetInstance<IInventoryItemAssembler>().WriteDto(inventoryItem);
        }
        public static InventoryItemDto Order(InventoryItemDto inventoryItemDto, String description)
        {
            if (!InventoryMovementValidator.ValidateOrder(inventoryItemDto))
                throw new InvalidOperationException("Inventory item must have a status of requested.");

            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

            inventoryItemRepository.Order(inventoryItem);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.REQUEST, description));

            return ObjectFactory.GetInstance<IInventoryItemAssembler>().WriteDto(inventoryItem);
        }
        public static void AssignInventoryItemToAthlete(InventoryItemDto inventoryItemDto, AthleteDto athleteDto)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            var athlete = athleteAssembler.ReadDto(athleteDto);

            inventoryItemRepository.Save(inventoryItem);

            inventoryItemDto.Status = Constants.Inventory.IN_STOCK;
            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
        }
        public static void Order(InventoryItemDto inventoryItemDto)
        {
            if (!InventoryMovementValidator.ValidateOrder(inventoryItemDto))
                throw new InvalidOperationException("Inventory item must have a status of requested.");

            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

            inventoryItemRepository.Order(inventoryItem);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.REQUEST, "Some message"));

            inventoryItemDto.Status = Constants.Inventory.ORDERED;
            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
        }
        public static InventoryItemDto Distribute(InventoryItemDto inventoryItemDto, String description)
        {
            if (!InventoryMovementValidator.ValidateDistribute(inventoryItemDto))
                throw new InvalidOperationException("Inventory item must have a status of in stock.");

            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

            inventoryItemRepository.Distribute(inventoryItem);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.DISTRIBUTE_TO_ATHLETE, description));

            return ObjectFactory.GetInstance<IInventoryItemAssembler>().WriteDto(inventoryItem);
        }
        public void CanAddNewAthlete()
        {
            var athleteDto = new AthleteDto();
            athleteDto.Nickname = "sheredia";
            athleteDto.FirstName = "Sarah";
            athleteDto.LastName = "Heredia";
            athleteDto.Gender = 'F';
            athleteDto.TrainerSizeW = 9;
            athleteDto.SpikeSizeW = 9.5;
            athleteDto.Notes = "Some notes on Sarah";
            athleteDto.Status = "Current";

            var poleVault = new EventAreaDto() { EventName = "PoleVault" };
            var sprints = new EventAreaDto() { EventName = "Sprints" };
            var modelDto = new ModelDto() { ModelNumber = "1234", ModelName = "name", Type = "runner", Color = "white", Price = 105, IsDiscontinued = false };

            var shoe1 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", Athlete = athleteDto, StatusLastChanged = DateTime.Now };
            var shoe2 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", Athlete = athleteDto , StatusLastChanged = DateTime.Now };

            athleteDto.EventParticipation.Add(poleVault);
            athleteDto.EventParticipation.Add(sprints);
            athleteDto.Inventory.Add(shoe1);
            athleteDto.Inventory.Add(shoe2);

            CoreAthleteService.SaveAthlete(athleteDto);

            var fromDb = ObjectFactory.GetInstance<IAthleteRepository>().GetByNickname(athleteDto.Nickname);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(athleteDto.Nickname, fromDb.Nickname);
            Assert.AreEqual(athleteDto.FirstName, fromDb.FirstName);
            Assert.AreEqual(athleteDto.LastName, fromDb.LastName);
            Assert.AreEqual(athleteDto.Gender, fromDb.Gender);
            Assert.AreEqual(athleteDto.SpikeSizeW, fromDb.SpikeSizeW);
            Assert.AreEqual(athleteDto.Notes, fromDb.Notes);
            Assert.AreEqual(athleteDto.Status, fromDb.Status);
            Assert.AreEqual(athleteDto.EventParticipation.Count, fromDb.EventAreas.Count);
            Assert.AreEqual(athleteDto.Inventory.Count, fromDb.Inventory.Count);
        }
        public static void Distribute(InventoryItemDto inventoryItemDto, AthleteDto athleteDto)
        {
            if (!InventoryMovementValidator.ValidateDistribute(inventoryItemDto))
                throw new InvalidOperationException("Inventory item must have a status of in stock.");

            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            var athlete = athleteAssembler.ReadDto(athleteDto);

            inventoryItemRepository.Distribute(inventoryItem, athlete);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.DISTRIBUTE_TO_ATHLETE, "Some message"));

            inventoryItemDto.Status = Constants.Inventory.DISTRIBUTED;
            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
        }
        public InventoryItem ReadDto(InventoryItemDto inventoryItemDto)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException();

            var inventoryMovementAssembler = ObjectFactory.GetInstance<IInventoryMovementAssembler>();
            var athleteRepository = ObjectFactory.GetInstance<IAthleteRepository>();
            var inventoryItem = ObjectFactory.GetInstance<IInventoryItemRepository>().GetBySerialNumber(inventoryItemDto.SerialNumber);

            if (inventoryItem == null)
                inventoryItem = new InventoryItem();
            else
                return inventoryItem;

            var model = ObjectFactory.GetInstance<IModelAssembler>().ReadDto(inventoryItemDto.ModelDto);
            var eventArea = ObjectFactory.GetInstance<IEventAreaAssembler>().ReadDto(inventoryItemDto.EventAreaAssignmentDto);
            var movementHistory = new HashedSet<InventoryMovement>();

            foreach (var movement in inventoryItemDto.MovementHistory)
                movementHistory.Add(inventoryMovementAssembler.ReadDto(movement));

            inventoryItem.SerialNumber = inventoryItemDto.SerialNumber;
            inventoryItem.Model = model;
            inventoryItem.SizeM = inventoryItemDto.SizeM;
            inventoryItem.SizeW = inventoryItemDto.SizeW;
            inventoryItem.Width = inventoryItemDto.Width;
            inventoryItem.RequestName = inventoryItemDto.RequestName;
            inventoryItem.Status = inventoryItemDto.Status;
            inventoryItem.StatusLastChanged = inventoryItemDto.StatusLastChanged;
            inventoryItem.EventAreaAssignment = eventArea;
            inventoryItem.Athlete = athleteRepository.GetByNickname(inventoryItemDto.AthleteNickname);
            inventoryItem.MovementHistory = movementHistory;

            model.InventoryItems.Add(inventoryItem);

            return inventoryItem;
        }
 public static Boolean ValidateSurplus(InventoryItemDto inventoryItemDto)
 {
     return inventoryItemDto.Status == Core.Constants.Inventory.IN_STOCK;
 }
 public static Boolean ValidateReturn(InventoryItemDto inventoryItemDto)
 {
     return inventoryItemDto.Status == Core.Constants.Inventory.IN_STOCK
         || inventoryItemDto.Status == Core.Constants.Inventory.DISTRIBUTED;
 }
 public static Boolean ValidateReceive(InventoryItemDto inventoryItemDto)
 {
     return inventoryItemDto.Status == Core.Constants.Inventory.ORDERED;
 }
 public static Boolean ValidateOrder(InventoryItemDto inventoryItemDto)
 {
     return inventoryItemDto.Status == Core.Constants.Inventory.REQUESTED;
 }
        public void SaveAthlete()
        {
            #region Setup objects
            var athleteDto = new AthleteDto();
            athleteDto.Nickname = "sheredia";
            athleteDto.FirstName = "Sarah";
            athleteDto.LastName = "Heredia";
            athleteDto.Gender = 'F';
            athleteDto.TrainerSizeW = 9;
            athleteDto.SpikeSizeW = 9.5;
            athleteDto.Notes = "Some notes on Sarah";
            athleteDto.Status = "Current";

            var eventAreaDto = new EventAreaDto();
            eventAreaDto.EventName = "Pole Vault";

            var modelDto = new ModelDto();
            modelDto.ModelNumber = "1234";
            modelDto.ModelName = "Model name";
            modelDto.Type = "Runner";
            modelDto.Color = "White";
            modelDto.Price = 105.00;
            modelDto.IsDiscontinued = false;

            var inventoryItemDto = new InventoryItemDto();
            inventoryItemDto.ModelDto = modelDto;
            inventoryItemDto.SizeM = 9;
            inventoryItemDto.SizeW = 11;
            inventoryItemDto.Width = "N";
            inventoryItemDto.RequestName = "request1";
            inventoryItemDto.Status = "Requested";
            //inventoryItemDto.AthleteDto = athleteDto;
            inventoryItemDto.StatusLastChanged = DateTime.Now;

            athleteDto.EventParticipation.Add(eventAreaDto);
            athleteDto.Inventory.Add(inventoryItemDto);

            var athlete = new Athlete();
            athlete.Nickname = "sheredia";
            athlete.FirstName = "Sarah";
            athlete.LastName = "Heredia";
            athlete.Gender = 'F';
            athlete.TrainerSizeW = 9;
            athlete.SpikeSizeW = 9.5;
            athlete.Notes = "Some notes on Sarah";
            athlete.Status = "Current";

            var eventArea = new EventArea();
            eventArea.EventName = "Pole Vault";

            var model = new Model();
            model.ModelNumber = "1234";
            model.ModelName = "Model name";
            model.Type = "Runner";
            model.Color = "White";
            model.Price = 105.00;
            model.IsDiscontinued = false;

            var inventoryItem = new InventoryItem();
            inventoryItem.Model = model;
            inventoryItem.SizeM = 9;
            inventoryItem.SizeW = 11;
            inventoryItem.Width = "N";
            inventoryItem.RequestName = "request1";
            inventoryItem.Status = "Requested";
            inventoryItem.Athlete = athlete;
            inventoryItem.StatusLastChanged = DateTime.Now;

            athlete.EventAreas.Add(eventArea);
            athlete.Inventory.Add(inventoryItem);
            #endregion

            _mockAthleteAssembler.Setup(x => x.ReadDto(athleteDto)).Returns(athlete);
            _mockAthleteRepository.Setup(x => x.Save(athlete));
            _mockAthleteAssembler.Setup(x => x.WriteDto(athlete)).Returns(new AthleteDto());

            AthleteService.SaveAthlete(athleteDto);

            _mockAthleteAssembler.VerifyAll();
            _mockAthleteRepository.VerifyAll();
        }
        public void SaveInventoryItem()
        {
            var model1 = new ModelDto() { ModelNumber = "524395-386", ModelName = "Air Pegasus+ 29 Trail", Type = "Running", Price = 105, Color = "Silver Sage/Team Red/University Red/Total Orange", IsDiscontinued = false };
            var inventoryItem1 = new InventoryItemDto() { ModelDto = model1, SizeM = 9, SizeW = 7, Width = 'N', RequestName = "request1", Status = Constants.Inventory.REQUESTED, StatusLastChanged = new DateTime(2012, 8, 18, 11, 26, 13) };

            inventoryItem1.SerialNumber = CoreInventoryService.SaveInventoryItem(inventoryItem1);

            var fromDb = _inventoryItemRepository.GetBySerialNumber(inventoryItem1.SerialNumber);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(inventoryItem1.SerialNumber, fromDb.SerialNumber);
        }
 public void Setup()
 {
     _inventoryItemDto = new InventoryItemDto();
 }
        public void Setup()
        {
            //_athleteDto = new AthleteDto() { Nickname = "sheredia", FirstName = "Sarah", LastName = "Heredia", Gender = 'F', TrainerSizeW = 9, SpikeSizeW = 9.5, Notes = "Some notes on Sarah", Status = "Current" };
            _modelDto = new Model() { ModelNumber = "1234", ModelName = "Model name", Type = "Runner", Color = "White", Price = 105.00, IsDiscontinued = false };
            _inventoryItemDto = new InventoryItem() { Model = _modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = Constants.Inventory.REQUESTED, StatusLastChanged = DateTime.Now };
            _inventoryItemRepository = ObjectFactory.GetInstance<InventoryItemRepository>();
            //_athleteDto.Inventory.Add(_inventoryItemDto);

            Bootstrapper.BootstrapStructureMap();
            ObjectFactory.GetInstance<IMySessionFactory>().ExportSchema();

            //CoreAthleteService.SaveAthlete(_athleteDto);
            _inventoryItemDto.SerialNumber = _inventoryItemRepository.Save(_inventoryItemDto);
        }
        public static InventoryItemDto ReturnedToVendor(InventoryItemDto inventoryItemDto, String description)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

            inventoryItemRepository.Return(inventoryItem);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.RETURN_TO_VENDOR, description));

            return ObjectFactory.GetInstance<IInventoryItemAssembler>().WriteDto(inventoryItem);
        }
        public void Setup()
        {
            _model = new Model() { ModelNumber = "524395-386", ModelName = "Air Pegasus+ 29 Trail", Type = "Running", Price = 105, Color = "Silver Sage/Team Red/University Red/Total Orange", IsDiscontinued = false };
            _inventoryItem = new InventoryItem() { Model = _model, Athlete = _athlete, SizeM = 9, SizeW = 7, Width = "N", RequestName = "request1", Status = Constants.Inventory.REQUESTED, StatusLastChanged = new DateTime(2012, 8, 18, 11, 26, 13) };
            _athlete = new Athlete() { FirstName = "Jeff", LastName = "Artis-Gray", Nickname = "JArtis-Gray", Gender = 'M', TrainerSizeM = 14, TrainerSizeW = 12, SpikeSizeM = 14, SpikeSizeW = 12, Notes = "Notes about Jeff Artis-Gray", Status = "Future" };
            _athlete.Inventory.Add(_inventoryItem);
            _inventoryItem.Athlete = _athlete;

            Bootstrapper.BootstrapStructureMap();
            ObjectFactory.GetInstance<IMySessionFactory>().ExportSchema();

            _inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            _athleteRepository = ObjectFactory.GetInstance<IAthleteRepository>();
            _inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            _athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();

            _inventoryItemDto = _inventoryItemAssembler.WriteDto(_inventoryItem);
            _athleteDto = _athleteAssembler.WriteDto(_athlete);

            ObjectFactory.GetInstance<IModelRepository>().Save(_model);
            _athleteRepository.Save(_athlete);
            _inventoryItemRepository.Save(_inventoryItem);
            _inventoryItemDto.SerialNumber = _inventoryItem.SerialNumber;
            _athleteDto.Id = _athlete.Id;
        }
        public static InventoryItemDto SaveInventoryItem(InventoryItemDto inventoryItemDto)
        {
            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();

            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            inventoryItemRepository.Save(inventoryItem);

            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.RECEIPT_FROM_VENDOR, "Pre-existing item"));

            return inventoryItemAssembler.WriteDto(inventoryItem);
        }
        public static InventoryItemDto Surplus(InventoryItemDto inventoryItemDto, String description)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

            inventoryItemRepository.Surplus(inventoryItem);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.SURPLUS, description));

            return ObjectFactory.GetInstance<IInventoryItemAssembler>().WriteDto(inventoryItem);
        }