public async System.Threading.Tasks.Task <OperationResult <Equipment> > CreateEquipment(Equipment equipment) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Equipment> >(() => { OperationResult <Equipment> result = new OperationResult <Equipment>(); try { if (IsInCompany()) { equipment.CompanyId = CurrentUser.CompanyId.Value; Equipment created = EquipmentsRepository.CreateOrUpdate(equipment); if (created.Id > 0) { result.SingleResult = created; result.Result = true; } } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }
public async System.Threading.Tasks.Task <OperationResult <Equipment> > GetEquipment(int pageSize, int pageNumber, bool descending) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Equipment> >(() => { OperationResult <Equipment> result = new OperationResult <Equipment>(); try { if (IsInCompany()) { result.Count = EquipmentsRepository.Count("CompanyId = @CompanyId", new { CompanyId = CurrentUser.CompanyId }); if (result.Count > 0) { result.MultipleResult = EquipmentsRepository.Search("CompanyId = @CompanyId", new { PageSize = pageSize, PageNumber = pageNumber, CompanyId = CurrentUser.CompanyId }, descending); } result.Result = true; } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }
public async System.Threading.Tasks.Task <OperationResult <OrderResponse> > GetCompanyForOrder(int id) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <OrderResponse> >(() => { OperationResult <OrderResponse> result = new OperationResult <OrderResponse>(); try { var company = CompaniesRepository.Read(id); if (company != null) { company.OwnerId = Guid.Empty; company.Description = ""; company.LogoImage = ""; var playgrounds = PlaygroundsRepository.Search("CompanyId = @CompanyId", new { PageNumber = 1, PageSize = 100, CompanyId = company.Id }); var gameTypes = GameTypesRepository.Search("CompanyId = @CompanyId", new { PageNumber = 1, PageSize = 100, CompanyId = company.Id }); var equipment = EquipmentsRepository.Search("CompanyId = @CompanyId", new { PageNumber = 1, PageSize = 100, CompanyId = company.Id }); foreach (var equip in equipment) { equip.State = ""; } result.SingleResult = new OrderResponse { Company = company, Playgrounds = playgrounds, GameTypes = gameTypes, Equipment = equipment }; result.Result = true; } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }
public async System.Threading.Tasks.Task <OperationResult <Equipment> > UpdateEquipment(Equipment equipment) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Equipment> >(() => { OperationResult <Equipment> result = new OperationResult <Equipment>(); try { if (IsInCompany(equipment.CompanyId)) { result.Result = EquipmentsRepository.Update(equipment); } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }
public async System.Threading.Tasks.Task <OperationResult <Equipment> > DeleteEquipment(int id) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Equipment> >(() => { OperationResult <Equipment> result = new OperationResult <Equipment>(); try { Equipment equipment = EquipmentsRepository.Read(id); if (equipment != null) { if (IsInCompany(equipment.CompanyId)) { result.Result = EquipmentsRepository.Delete(id); } } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }
public EquipmentsManager(EquipmentsRepository equipmentsRepository) { _equipmentsRepository = equipmentsRepository; }
public EquipmentsController(EquipmentsRepository repository) { _repository = repository ?? throw new ArgumentNullException(nameof(repository)); }
public RentalsService(RentalsRepository rr, EquipmentsRepository er) { _rentalsRepository = rr; _equipmentsRepository = er; }