public AuthorizationProvider(IAuthorizationService <JwtResponse> authorizationService, ISessionService <UserSession> sessionService, ITokenStorage tokenStorage) { _authorizationService = Has.NotNull(authorizationService); _sessionService = Has.NotNull(sessionService); _tokenStorage = Has.NotNull(tokenStorage); }
public OrderProvider(IUnitOfWork unitOfWork, ICustomerService customerService, IProductService productService, IMapper mapper) { _unitOfWork = Has.NotNull(unitOfWork); _customerService = Has.NotNull(customerService); _productSerivice = Has.NotNull(productService); _mapper = Has.NotNull(mapper); }
public RepositoryBase(IMongoDatabase database, string tableName, bool searchable = true) { _collection = Has.NotNull(database).GetCollection <TEntity>(tableName); if (searchable) { CreateIndex(); } }
public GroupProvider(IUnitOfWork unitOfWork, IStudentService studentService, IEmployeeService employeeService, IMapper mapper) { _unitOfWork = Has.NotNull(unitOfWork); _studentService = Has.NotNull(studentService); _employeeService = Has.NotNull(employeeService); _mapper = Has.NotNull(mapper); }
public async Task <object> ShowAsync(ViewModelBase viewModel) { Has.NotNull(viewModel); var dialogView = ViewDialogLocator.View(viewModel); dialogView.DataContext = viewModel; return(await DialogHost.Show(dialogView, "RootDialog")); }
public BaseApiService(IReaderTokenStore tokenStorage, HttpClient httpClient) { _tokenStorage = Has.NotNull(tokenStorage); HttpClient = Has.NotNull(httpClient); HttpClient.SetBearerToken(_tokenStorage[Tokens.Access]); _tokenStorage.Changed += OnTokentChanged; _tokenStorage.Cleared += OnCleared; }
/// <summary> /// Deletes installed links in groups /// </summary> /// <typeparam name="T"></typeparam> /// <param name="referencesAction"></param> /// <param name="model"></param> /// <returns></returns> public async Task Exclude(Action <IReferencesDeleteable> referencesAction, IGroupsReferense model) { Has.NotNull(model); foreach (var id in model.Groups) { var groupEntity = await _unitOfWork.Groups.GetByIdAsync(id); if (groupEntity == null) { throw new InvalidOperationException($"Missing id specified: {id}"); } referencesAction?.Invoke(groupEntity); await _unitOfWork.Groups.UpdateAsync(id, groupEntity); } }
/// <summary> /// Deleted installed links in Orders /// </summary> /// <param name="referencesAction"></param> /// <param name="model"></param> /// <returns></returns> public async Task Exclude(Action <IReferenceDeletable> referencesAction, IOrdersReference model) { Has.NotNull(model); foreach (var id in model.Orders) { var orderEntity = await _unitOfWork.Orders.GetByIdAsync(id); if (orderEntity == null) { throw new InvalidOperationException($"Missing id specified: {id}"); } referencesAction?.Invoke(orderEntity); await _unitOfWork.Orders.UpdateAsync(id, orderEntity); } }
private async Task <Group> MapToModel(GroupEntity entity) { var model = _mapper.Map <Group>(Has.NotNull(entity)); if (entity.TeacherId != default) { var teacher = await _employeeService.GetByIdAsync(entity.TeacherId); model.Teacher = teacher; } entity.StudentsIds?.SelectAsync(async id => { Has.NotNull(model.Students).Add(await _studentService.GetByIdAsync(id)); return(id); }); return(model); }
public async Task UpdateAsync(Guid id, OrderUpdate model) { Has.NotNull(model); if (!id.Equals(model.Id)) { throw new InvalidOperationException($"This IDs don't match: {id} and {model.Id}"); } var entity = await _unitOfWork.Orders.GetByIdAsync(model.Id); await _unitOfWork.SetAllReferences(DeletedOrderReference.GetInstance(entity, model)); //Adding new links received from the UI await _unitOfWork.SetAllReferences(InsertOrderReferences.GetInstance(entity, model)); await _unitOfWork.Orders.UpdateAsync(id, _mapper.Map(model, entity)); }
private async Task <OrderDto> MapToModel(Order entity) { var model = _mapper.Map <OrderDto>(Has.NotNull(entity)); if (entity.CustomerId != default) { var customer = await _customerService.GetByIdAsync(entity.CustomerId); model.Customer = customer; } entity.ProductsIds?.SelectAsync(async id => { Has.NotNull(model.Products).Add(await _productSerivice.GetByIdAsync(id)); return(id); }); return(model); }
public async Task UpdateAsync(Guid id, GroupUpdate model) { Has.NotNull(model); if (!id.Equals(model.Id)) { throw new InvalidOperationException($"The IDs don't match: {id} and {model.Id}"); } var entity = await _unitOfWork.Groups.GetByIdAsync(model.Id); /// This is not a bug but a feature: /// When you change the reference to the group in the Student and Employee objects is not deleted so you have to delete it manually await _unitOfWork.SetAllReferences(DeletedGroupReference.GetInstance(entity, model)); /// Adding new links received from the UI await _unitOfWork.SetAllReferences(InsertedGroupReference.GetInstance(entity, model)); await _unitOfWork.Groups.UpdateAsync(id, _mapper.Map(model, entity)); }
public async Task InsertAsync(ProductDto model) { var entity = _mapper.Map <Product>(Has.NotNull(model)); await _repository.InsertAsync(entity); }
public StudentService(IUnitOfWork dataProvider, IMapper mapper) { _repository = Has.NotNull(dataProvider).Students; _mapper = Has.NotNull(mapper); }
public ProductService(IUnitOfWork unitOfWork, IMapper mapper) { _repository = Has.NotNull(unitOfWork).Products; _mapper = Has.NotNull(mapper); }
public ProductManager(IUnitOfWork unitOfWork, IReferenceExcludable excludable, IProductService productService) { _excludable = Has.NotNull(excludable); _productService = Has.NotNull(productService); _unitOfWork = Has.NotNull(unitOfWork); }
public async Task UpdateAsync(Guid id, ProductDto model) => await _productService.UpdateAsync(id, Has.NotNull(model));
public async Task UpdateAsync(Guid id, Student model) { await _studentService.UpdateAsync(id, Has.NotNull(model)); }
public async Task UpdateAsync(Guid id, CustomerDto model) { var entity = _mapper.Map <Customer>(Has.NotNull(model)); await _repository.UpdateAsync(id, entity); }
public async Task InsertAsync(OrderDto model) { var entity = _mapper.Map <Order>(Has.NotNull(model)); await _unitOfWork.Orders.InsertAsync(entity); }
public CustomerService(IUnitOfWork unitOfWork, IMapper mapper) { _repository = Has.NotNull(unitOfWork).Customers; _mapper = Has.NotNull(mapper); }
public StudentManager(IUnitOfWork unitOfWork, IReferenceExcludable excludable, IStudentService studentService) { _excludable = Has.NotNull(excludable); _studentService = Has.NotNull(studentService); _unitOfWork = Has.NotNull(unitOfWork); }
public async Task UpdateAsync(Guid id, Employee model) { await _employeeService.UpdateAsync(id, Has.NotNull(model)); }
public EmployeeManager(IUnitOfWork unitOfWork, IReferenceExcludable excludable, IEmployeeService employeeService) { _excludable = Has.NotNull(excludable); _employeeService = Has.NotNull(employeeService); _unitOfWork = Has.NotNull(unitOfWork); }
public async Task UpdateAsync(Guid id, CustomerDto model) => await _customerService.UpdateAsync(id, Has.NotNull(model));
public async Task InsertAsync(Employee model) { await _employeeService.InsertAsync(Has.NotNull(model)); }
public async Task UpdateAsync(Guid id, ProductDto model) { var entity = _mapper.Map <Product>(Has.NotNull(model)); await _repository.UpdateAsync(id, entity); }
public async Task InsertAsync(CustomerDto model) { var entity = _mapper.Map <Customer>(Has.NotNull(model)); await _repository.InsertAsync(entity); }
public async Task InsertAsync(GroupCreate model) { var entity = _mapper.Map <GroupEntity>(Has.NotNull(model)); await _unitOfWork.Groups.InsertAsync(entity); }
public async Task InsertAsync(Student model) { await _studentService.InsertAsync(Has.NotNull(model)); }