public ServerReportAddresses() { InitializeComponent(); oServiceTypeRep = new ServiceTypeRepository(); oDonorRepo = new DonorRepository(); lstServiceType = oServiceTypeRep.GetAllAsQuerable().ToList(); }
public void GetAllServiceTypes() { var serviceType = new ServiceType() { Id = 1, Name = "repair" }; var serviceTypes = new List <ServiceType>(); serviceTypes.Add(serviceType); var dbSetMock = new Mock <DbSet <ServiceType> >(); dbSetMock.As <IQueryable <ServiceType> >().Setup(x => x.Provider).Returns(serviceTypes.AsQueryable().Provider); dbSetMock.As <IQueryable <ServiceType> >().Setup(x => x.Expression).Returns(serviceTypes.AsQueryable().Expression); dbSetMock.As <IQueryable <ServiceType> >().Setup(x => x.ElementType).Returns(serviceTypes.AsQueryable().ElementType); dbSetMock.As <IQueryable <ServiceType> >().Setup(x => x.GetEnumerator()).Returns(serviceTypes.AsQueryable().GetEnumerator()); var context = new Mock <TicketDbContext>(); context.Setup(x => x.Set <ServiceType>()).Returns(dbSetMock.Object); var repository = new ServiceTypeRepository(context.Object); var result = repository.GetAll(); Assert.AreEqual(serviceTypes, result); }
public List <ServiceType> SelectAllCuntries() { var returnedEntities = new List <ServiceType>(); try { using (var repository = new ServiceTypeRepository()) { foreach (var entity in repository.SelectAll()) { //entity.NetSalary = GetNetSalary(entity.GrossSalary, entity.Age); returnedEntities.Add(entity); } } return(returnedEntities); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:ServiceTypeBusiness::SelectAllServiceType::Error occured.", ex); } }
public static List <ServiceTypeModel> GetAll() { try { var repo = new ServiceTypeRepository(); return(repo.GetAll()); } catch (Exception ex) { throw ex; } }
public void Initialize() { var serviceTypes = GetFakeData(); _dbContextMock = new DbContextMock <DatabaseContext>(DummyOptions); var dbSetMock = _dbContextMock.CreateDbSetMock(x => x.ServiceTypes, serviceTypes); var repository = new ServiceTypeRepository(_dbContextMock.Object); _service = new ServiceTypeService(repository); }
public TicketConverter(PriorityRepository priorityRepository, ServiceTypeRepository serviceTypeRepository, StatusRepository statusRepository, TicketTypeRepository ticketTypeRepository, UserRepository userRepository) { _priorityRepository = priorityRepository; _serviceTypeRepository = serviceTypeRepository; _statusRepository = statusRepository; _ticketTypeRepository = ticketTypeRepository; _userRepository = userRepository; }
public DailyAnnadanam(string PrinterName,bool ShowPrintPreview) { this.MaximizeBox = false; dailyAnnaRepo = new DailyAnnaDanamRepository(); gothramRepo = new GothramsRepository(); serviceTypeRepo = new ServiceTypeRepository(); oPrintHelper = new PrintHelper(); lstTokenPrint = new List<TokenPrint>(); _PrinterName = PrinterName; _ShowPrintPreview = ShowPrintPreview; InitializeComponent(); }
public DailyAnnadanam(string PrinterName, bool ShowPrintPreview) { this.MaximizeBox = false; dailyAnnaRepo = new DailyAnnaDanamRepository(); gothramRepo = new GothramsRepository(); serviceTypeRepo = new ServiceTypeRepository(); oPrintHelper = new PrintHelper(); lstTokenPrint = new List <TokenPrint>(); _PrinterName = PrinterName; _ShowPrintPreview = ShowPrintPreview; InitializeComponent(); }
public void Edit(ServiceTypeModel viewModel) { var updatedServiceType = ServiceTypeRepository.Items.Include("ServiceOfferings.Program.Schools").Include(s => s.Categories).Include("ServiceOfferings.Program").SingleOrDefault(s => s.Id == viewModel.Id); if (updatedServiceType == null) { throw new EntityNotFoundException("Service Type not found."); } viewModel.CopyTo(updatedServiceType); ServiceTypeRepository.Update(updatedServiceType); UpdateTypeCategories(viewModel.SelectedCategories, updatedServiceType); UpdateServiceTypePrograms(viewModel.SelectedPrograms, updatedServiceType); RepositoryContainer.Save(); }
public DonationInformation() { //dtpDate.MinDate = DateTime.Now; this.MaximizeBox = false; InitializeComponent(); dtpEnglishDateType.Format = DateTimePickerFormat.Custom; dtpEnglishDateType.CustomFormat = "dd/MM"; donorRepo = new DonorRepository(); datetypeRepo = new DateTypeRepository(); desigRepo = new DesignationRepository(); employeeRepo = new EmployeeRepository(); prefixRepo = new PrefixesRepository(); roleRepo = new RoleRepository(); serviceNameRepo = new ServiceNameRepository(); serviceTypeRepo = new ServiceTypeRepository(); specialDayRepo = new SpecialDayRepository(); starRepo = new StarsRepository(); monthsRepo = new MonthsRepository(); pakshaRepo = new PakshaRepository(); thithiRepo = new ThidhiRepository(); monthlyAnnaRepo = new MonthlyAnnaRepository(); gothramRepo = new GothramsRepository(); transTypeRepo = new TransactionTypeRepository(); lstTokenPrint = new List<TokenPrint>(); stateRepo = new StateRepository(); lstStates = new List<State>(); prefixesRepo = new PrefixesRepository(); bindData(); btnUpdate.Visible = false; btnCancel.Visible = false; lblSpecialDay.Visible = false; cmbSpecialDay.Visible = false; lblMonth.Visible = false; cmbMonth.Visible = false; lblThithi.Visible = false; cmbThithi.Visible = false; lblMonthlyAnna.Visible = false; cmbMonthlyAnna.Visible = false; lblEnglishDatetype.Visible = false; dtpEnglishDateType.Visible = false; rbdEnglish.Checked = false; rbdTelugu.Checked = false; lblMonthyAnnaThithi.Visible = false; cmbMonthyAnnaThithi.Visible = false; }
public void SetPrivacy(EducationSecurityPrincipal user, int typeId, bool isPrivate) { IPermission permission = PermissionFactory.Current.Create("SetServiceTypePrivacy"); permission.GrantAccess(user); ServiceType serviceType = ServiceTypeRepository.Items.SingleOrDefault(s => s.Id == typeId); if (serviceType == null) { throw new EntityNotFoundException("Service Type with the specified ID was not found."); } serviceType.IsPrivate = isPrivate; ServiceTypeRepository.Update(serviceType); RepositoryContainer.Save(); }
public void AddNewServiceType() { var serviceType = new ServiceType(); var context = new Mock <TicketDbContext>(); var dbSetMock = new Mock <DbSet <ServiceType> >(); context.Setup(x => x.Set <ServiceType>()).Returns(dbSetMock.Object); dbSetMock.Setup(x => x.Add(It.IsAny <ServiceType>())).Returns(serviceType); var repository = new ServiceTypeRepository(context.Object); repository.Add(serviceType); context.Verify(x => x.Set <ServiceType>()); dbSetMock.Verify(x => x.Add(It.Is <ServiceType>(y => y == serviceType))); }
public async Task GetServiceTypesAsync_Returns_GetServiceTypeDtos() { //Arrange _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypesAsync()) .ReturnsAsync(_fixture.ServiceTypes); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var result = await repository.GetServiceTypesAsync(); //Assert var serviceType = result.Should().BeAssignableTo <IEnumerable <GetServiceTypeDto> >().Subject; serviceType.Should().HaveCount(2); }
public async Task CreateServiceTypeAsync_Returns_New_GetServiceTypeDto() { //Arrange _fixture.MockServiceTypeService.Setup(x => x.AddServiceTypeAsync(It.IsAny <ServiceType>())) .ReturnsAsync(_fixture.CreatedNewServiceType); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var result = await repository.CreateServiceTypeAsync(_fixture.CreateServiceTypeDto); //Assert result.Should().BeOfType(typeof(GetServiceTypeDto)); result.Id.Should().Be(3); result.Type.Should().Be(_fixture.CreateServiceTypeDto.Type); }
public bool DeleteServiceTypeById(int empId) { try { using (var repository = new ServiceTypeRepository()) { return(repository.DeleteById(empId)); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:ServiceTypesBusiness::DeleteServiceTypeById::Error occured.", ex); } }
public async Task DeleteServiceTypeAsync_Returns_NoResult() { //Arrange var id = 2; _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypeAsync(It.IsAny <Expression <Func <ServiceType, bool> > >())) .Returns <Expression <Func <ServiceType, bool> > >(expression => Task.FromResult(_fixture.ServiceTypes.AsQueryable().FirstOrDefault(expression))); _fixture.MockServiceTypeService.Setup(x => x.DeleteServiceTypeAsync(It.IsAny <ServiceType>())); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act await repository.DeleteServiceTypeAsync(id); // Assert _fixture.MockServiceTypeService.Verify(x => x.DeleteServiceTypeAsync(It.IsAny <ServiceType>()), Times.Once); }
public async Task GetServiceTypeAsync_Returns_GetServiceTypeDto() { //Arrange var id = 2; _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypeAsync(It.IsAny <Expression <Func <ServiceType, bool> > >())) .Returns <Expression <Func <ServiceType, bool> > >(expression => Task.FromResult(_fixture.ServiceTypes.AsQueryable().FirstOrDefault(expression))); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var result = await repository.GetServiceTypeAsync(id); //Assert result.Should().BeOfType(typeof(GetServiceTypeDto)); result.Id.Should().Be(id); result.Type.Should().Be("Dine In"); }
public async Task GetServiceTypeAsync_Throws_NotFoundException() { //Arrange var id = 201; _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypeAsync(It.IsAny <Expression <Func <ServiceType, bool> > >())) .Returns <Expression <Func <ServiceType, bool> > >(expression => Task.FromResult(_fixture.ServiceTypes.AsQueryable().FirstOrDefault(expression))); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.GetServiceTypeAsync(id)); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.NotFound); exception.ErrorMessage.Should().Be("Service type not found."); exception.ErrorType.Should().Be(HttpStatusCode.NotFound.ToString()); }
public async Task CreateServiceTypeAsync_Throws_ConflictException() { //Arrange _fixture.MockServiceTypeService.Setup(x => x.GetServiceTypeAsync(It.IsAny <Expression <Func <ServiceType, bool> > >())) .Returns <Expression <Func <ServiceType, bool> > >(expression => Task.FromResult(_fixture.ServiceTypes.AsQueryable().FirstOrDefault(expression))); var repository = new ServiceTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockServiceTypeService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.CreateServiceTypeAsync(new CreateServiceTypeDto { Type = "dine in" })); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.Conflict); exception.ErrorMessage.Should().Be("Service type \"dine in\" is already available."); exception.ErrorType.Should().Be(HttpStatusCode.Conflict.ToString()); }
private void UpdateTypeCategories(IEnumerable <int> SelectedCategories, ServiceType serviceType) { List <Category> selectedCategories = (SelectedCategories == null || !SelectedCategories.Any()) ? new List <Category>() : CategoryRepository.Items.Where(s => SelectedCategories.Contains(s.Id)).ToList(); IEnumerable <Category> categorySet = selectedCategories.Union(serviceType.Categories.ToArray()); foreach (Category category in categorySet) { if (!selectedCategories.Contains(category)) { ServiceTypeRepository.DeleteLink(serviceType, category); } else if (!serviceType.Categories.Contains(category)) { ServiceTypeRepository.AddLink(serviceType, category); } } }
public DonorMasterReportUI() { InitializeComponent(); oServiceTypeRep = new ServiceTypeRepository(); oServiceNameRep = new ServiceNameRepository(); oDateTypeRepository = new DateTypeRepository(); oDonorRepository = new DonorRepository(); oSpecialDayRepository = new SpecialDayRepository(); oMonthsRepository = new MonthsRepository(); oThidhiRepository = new ThidhiRepository(); oTeluguCalendarRepository = new TeluguCalendarRepository(); // oPakshaRepository = new PakshaRepository(); lstServiceType = oServiceTypeRep.GetAllAsQuerable().ToList(); lstMonths = oMonthsRepository.GetAllAsQuerable().ToList(); lstThidhi = oThidhiRepository.GetAllAsQuerable().ToList(); lstDateType = oDateTypeRepository.GetAllAsQuerable().ToList(); lstDateType.RemoveAt(0); lstSpecialDay = oSpecialDayRepository.GetAllAsQuerable().ToList(); // lstPaksha = oPakshaRepository.GetAllAsQuerable().ToList(); }
public bool UpdateServiceType(ServiceType entity) { try { bool bOpDoneSuccessfully; using (var repository = new ServiceTypeRepository()) { bOpDoneSuccessfully = repository.Update(entity); } return(bOpDoneSuccessfully); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:ServiceTypesBusiness::UpdateServiceType::Error occured.", ex); } }
private void FillServiceType() { var repository = new ServiceTypeRepository(); repository.AddIfNotExist(new ServiceType() { Name = "Transmission" }); repository.AddIfNotExist(new ServiceType() { Name = "Vehicle Maintance" }); repository.AddIfNotExist(new ServiceType() { Name = "Vehicle Repair" }); repository.AddIfNotExist(new ServiceType() { Name = "Other" }); }
public ServiceType SelectServiceTypeById(int empId) { try { ServiceType returnedEntity; using (var repository = new ServiceTypeRepository()) { returnedEntity = repository.SelectById(empId); //if (returnedEntity != null) //returnedEntity.NetSalary = GetNetSalary(returnedEntity.GrossSalary, returnedEntity.Age); } return(returnedEntity); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:ServiceTypeBusiness::SelectServiceTypeById::Error occured.", ex); } }
public void Create(ServiceTypeModel viewModel) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } ServiceType item = new ServiceType { IsActive = true }; viewModel.CopyTo(item); if (ServiceTypeRepository.Items.Any(s => s.Name == item.Name && !s.IsActive)) { item = ServiceTypeRepository.Items.Include("ServiceOfferings.Program.Schools").Single(s => s.Name == item.Name); item.IsActive = true; } else { ServiceTypeRepository.Add(item); } UpdateTypeCategories(viewModel.SelectedCategories, item); UpdateServiceTypePrograms(viewModel.SelectedPrograms, item); RepositoryContainer.Save(); }
public ServiceTypeService(ServiceTypeRepository repository) { _repository = repository; }
public ManageServiceDetails() { InitializeComponent(); servRepo = new ServiceTypeRepository(); HideControls(false); }
public TRepository GetRepository <TRepository>(IUnitOfWork unitOfWork) where TRepository : class { if (typeof(TRepository) == typeof(IBedRepository)) { dynamic repo = new BedRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IRoomRepository)) { dynamic repo = new RoomRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IOutletRepository)) { dynamic repo = new OutletRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(ICustomerRepository)) { dynamic repo = new CustomerRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(ITherapistRepository)) { dynamic repo = new TherapistRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IServiceRepository)) { dynamic repo = new ServiceRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IService_BedRepository)) { dynamic repo = new Service_BedRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IAppoitmentDetailRepository)) { dynamic repo = new AppoitmentDetailRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IReviewOutletRepository)) { dynamic repo = new ReviewOutletRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(ITimeSlotRepository)) { dynamic repo = new TimeSlotRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IReviewOutletRepository)) { dynamic repo = new ReviewOutletRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IBufferTimeRepository)) { dynamic repo = new BufferTimeRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IAppoitmentRepository)) { dynamic repo = new AppoitmentRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IOutlet_StaffRepository)) { dynamic repo = new Outlet_StaffRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IMeasurementRepository)) { dynamic repo = new MeasurementRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IServiceTypeRepository)) { dynamic repo = new ServiceTypeRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } if (typeof(TRepository) == typeof(IReviewServiceRepository)) { dynamic repo = new ReviewServiceRepository(); repo.UnitOfWork = unitOfWork; return((TRepository)repo); } TRepository repository = null; return(repository); }