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