Beispiel #1
0
        public Rig GenerateRig(string rigType, string name, string description)
        {
            RigTemplate rigTemplate = m_rigTemplateRepository.GetRigTemplate(rigType);

            Rig rig = m_rigRepository.Create(rigType, name, description);

            foreach (EquipmentTemplate equipmentTemplate in rigTemplate.EquipmentTemplates)
            {
                Equipment currentEquipment = m_equipmentRepository.Create(rig.Id, null, equipmentTemplate.Name, equipmentTemplate.Type, equipmentTemplate.IsSystem);
                currentEquipment.Fields.AddRange(equipmentTemplate.Fields);

                foreach (EquipmentTemplate subTemplate in equipmentTemplate.SubTemplates)
                {
                    // All sub items must set isSystem to false.
                    Equipment subEquipment = m_equipmentRepository.Create(rig.Id, currentEquipment.Id, subTemplate.Name, subTemplate.Type, isSystem: false);
                    subEquipment.Fields.AddRange(subTemplate.Fields);

                    m_equipmentRepository.Update(subEquipment);
                }

                m_equipmentRepository.Update(currentEquipment);
            }

            return(rig);
        }
        public void CreateEquipment()
        {
            var equipment = new Equipment {
                EquipmentName = EquipmentType.Laptop, IsAvaliable = true, IsWorking = true
            };
            var equipment1 = new Equipment {
                EquipmentName = EquipmentType.Phone, IsAvaliable = true, IsWorking = false
            };

            Assert.That(equipment, !Is.Null);
            Assert.That(equipment1, !Is.Null);
            equipmentRepository.Create(equipment);
            equipmentRepository.Create(equipment1);
            contextManager.BatchSave();

            Assert.That(equipment, !Is.Null);
            Assert.That(equipment.Id, !Is.NaN);
            Assert.That(equipment.Id, Is.Positive);
            Assert.IsInstanceOf(typeof(int), equipment.Id);

            Assert.That(equipment1, !Is.Null);
            Assert.That(equipment1.Id, !Is.NaN);
            Assert.That(equipment1.Id, Is.Positive);
            Assert.IsInstanceOf(typeof(int), equipment1.Id);
        }
        public void Add(EquipmentData equipmentData)
        {
            _unitOfWork.BeginTransaction();

            _equipmentRepository.Create(equipmentData);

            _unitOfWork.Commit();
        }
Beispiel #4
0
        public void GenerateRig_CreatesEquipment_For_Every_EquipmentTemplate_In_RigTemplate()
        {
            RigTemplate rigTemplate = GetRigTemplate();

            A.CallTo(() => m_rigTemplateRepo.GetRigTemplate("Jackup")).Returns(rigTemplate);

            Rig rig = new Rig()
            {
                Id = Guid.NewGuid().ToString()
            };

            A.CallTo(() => m_rigRepo.Create("Jackup", string.Empty, string.Empty)).Returns(rig);

            m_testSubject.GenerateRig("Jackup", string.Empty, string.Empty);

            foreach (EquipmentTemplate equipmentTemplate in rigTemplate.EquipmentTemplates)
            {
                A.CallTo(() => m_equipmentRepo.Create(rig.Id, null, equipmentTemplate.Name, equipmentTemplate.Type, false)).MustHaveHappenedOnceExactly();
            }
        }
Beispiel #5
0
        public IActionResult Create([Bind("Name,Description,ImageUrl,Cost,Category,Strength,Intelligence,Agility")]
                                    Equipment equipment)
        {
            if (!ModelState.IsValid)
            {
                return(View(new EquipmentCreateViewModel(equipment)));
            }

            _repo.Create(equipment);

            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public ICommandResult Handle(CreateEquipmentCommand command)
        {
            var equipment = new Equipment(command.Description);

            AddNotifications(equipment.Notifications);
            if (Invalid)
            {
                return(new CommandResult(false, "Ocorreu um erro ao criar equipamento", Notifications));
            }

            _repository.Create(command);
            return(new CommandResult(true, "Equipamento criado com sucesso", null));
        }
        public Equipment Create(CreateEquipmentCommand command)
        {
            var equipment = new Equipment(command.IdTypeEquipment, command.Description, command.Model, command.SerialNumber, command.DateBuy, command.Patrimony);

            equipment.Create();
            _repository.Create(equipment);

            if (Commit())
            {
                return(equipment);
            }

            return(null);
        }
        public IBaseCommandResult Handle(CreateEquipmentCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new BaseCommandResult(false, "Need to fix the errors on Equipment", command.Notifications));
            }

            var user = _userRepository.GetById(command.UserId);

            if (user == null)
            {
                return(new BaseCommandResult(false, "User not found", null));
            }

            //logic here: if manufacturer and/or model don't exists, i will create it and attach to equipment
            var manufacturer = _manufacturerRepository.GetByDescription(command.Manufacturer);

            if (manufacturer == null)
            {
                manufacturer = new Manufacturer(command.Manufacturer);
                _manufacturerRepository.Create(manufacturer);
            }

            var deviceModel = _deviceModelRepository.GetByDescriptionAndManufacturer(command.Model, manufacturer);

            if (deviceModel == null)
            {
                deviceModel = new DeviceModel(command.Model, manufacturer);
                _deviceModelRepository.Create(deviceModel);
            }

            var equipment = new Equipment(command.AndroidId, command.Imei1, command.Imei2, command.PhoneNumber, command.MacAddress,
                                          command.ApiLevel, command.ApiLevelDesc, command.SerialNumber, command.SystemName, command.SystemVersion, deviceModel, user);

            _repository.Create(equipment);

            return(new BaseCommandResult(true, "Equipment Saved with Success!", new { Id = equipment.Id.ToString() }));
        }
Beispiel #9
0
 public Equipment CreateEquipment(string rigId, string parentId, string name, string type, bool isSystem) => m_equipmentRepo.Create(rigId, parentId, name, type, isSystem);