public static EquipmentAggregate ToModel(this EquipmentCreateViewModel model)
        {
            EquipmentAggregate entity = null;

            if (model != null)
            {
                var    ids   = Regex.Split(model.DepartmentId, @"#\$#").ToList();
                string fId   = ids[0];
                string fName = "";
                if (ids.Count() > 1)
                {
                    fName = ids[1];
                }
                entity = new EquipmentAggregate()
                {
                    Id             = Guid.NewGuid(),
                    Name           = model.Name,
                    Model          = model.EquipmentModel,
                    DepartmentId   = new  Guid(fId),
                    DepartmentName = fName.Replace("#+#", " "),
                    Description    = model.Description,
                };
            }

            return(entity);
        }
Beispiel #2
0
 /// <summary>The add.</summary>
 /// <param name="equipment">The equipment.</param>
 public void Add(EquipmentAggregate equipment)
 {
     if (!this.Equipments.Contains(equipment))
     {
         this.Equipments.Add(equipment);
     }
 }
        public void EquipmentAggregateRepositoty_GetByIdValidIdTest()
        {
            Guid guid = new Guid("602D9F0C-40DA-4FCE-8C4D-F22748D5FB2D");
            IEquipmentAggregateRepository repo      = IoCFactory.Instance.CurrentContainer.Resolve <IEquipmentAggregateRepository>();
            EquipmentAggregate            equipment = repo.GetElementById(guid);

            Assert.IsNotNull(equipment);
            Assert.IsTrue(equipment.Id == guid);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="organization"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task AddEquipmentAsync(EquipmentAggregate equipmentAggregate, CancellationToken cancellationToken = default(CancellationToken))
 {
     cancellationToken.ThrowIfCancellationRequested();
     if (equipmentAggregate == (EquipmentAggregate)null)
     {
         throw new ArgumentNullException("equipmentAggregate");
     }
     _equipmentAggregateRepository.Add(equipmentAggregate);
     return(Task.Run(() =>
     {
         _equipmentAggregateRepository.UnitOfWork.Commit();
     }));
 }
        public void EquipmentAggregateRepositoty_AddTest()
        {
            IEquipmentAggregateRepository repo      = IoCFactory.Instance.CurrentContainer.Resolve <IEquipmentAggregateRepository>();
            EquipmentAggregate            equipment = new EquipmentAggregate()
            {
                Id             = Guid.NewGuid(),
                DepartmentId   = Guid.NewGuid(),
                DepartmentName = "test facility",
                Model          = "Type of equipment",
                Name           = "test equipment"
            };

            repo.Add(equipment);
            repo.UnitOfWork.Commit();
            var all = repo.GetAllElements();

            Assert.IsNotNull(all);
            Assert.IsTrue(all.Count() > 1);
        }