public static DepartmentAggregate ToModel(this DepartmentCreateViewModel model)
        {
            DepartmentAggregate entity = null;

            if (model != null)
            {
                var    ids   = Regex.Split(model.FacilityId, @"#\$#").ToList();
                string fId   = ids[0];
                string fName = "";
                if (ids.Count() > 1)
                {
                    fName = ids[1];
                }
                entity = new DepartmentAggregate()
                {
                    Id           = Guid.NewGuid(),
                    Name         = model.Name,
                    FacilityId   = new Guid(fId),
                    FacilityName = fName,
                    Description  = model.Description,
                };
            }

            return(entity);
        }
        public void DepartmentAggregateRepository_GetByIdValidIdTest()
        {
            Guid guid = new Guid("62588897-8e83-cf15-3239-08d20141829a");
            IDepartmentAggregateRepository repo = IoCFactory.Instance.CurrentContainer.Resolve <IDepartmentAggregateRepository>();
            DepartmentAggregate            dep  = repo.GetElementById(guid);

            Assert.IsNotNull(dep);
            Assert.IsTrue(dep.Id == guid);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="department"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task AddDepartmentAsync(DepartmentAggregate department, CancellationToken cancellationToken = default(CancellationToken))
 {
     cancellationToken.ThrowIfCancellationRequested();
     if (department == (DepartmentAggregate)null)
     {
         throw new ArgumentNullException("department");
     }
     _departmentAggregateRepository.Add(department);
     return(Task.Run(() =>
     {
         _departmentAggregateRepository.UnitOfWork.Commit();
     }));
 }