/// <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); }
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; }