public OrdersController(WorkshopContext context, IMemoryCache memoryCache, WorkshopService service) { db = context; this.memoryCache = memoryCache; this.service = service; }
public ActionResult AddService(WorkshopServiceModel viewModel) { var session = Session["LoginWorkshop"] as SessionModel; if (session != null) { using (var db = new MechAppProjectEntities()) { var workshopService = new WorkshopService() { WorkshopId = session.WorkshopId, Title = viewModel.Title, Description = viewModel.Description, Price = viewModel.Price.HasValue ? viewModel.Price.Value : 0, PriceDecimal = viewModel.PriceDecimal.HasValue ? viewModel.PriceDecimal.Value : 0, DurationInHrs = viewModel.DurationInHours.HasValue ? viewModel.DurationInHours.Value : 0, DurationInMinutes = viewModel.DurationInMinutes.HasValue ? viewModel.DurationInMinutes.Value : 0 }; db.WorkshopServices.Add(workshopService); db.SaveChanges(); } } return(RedirectToAction("Index")); }
public async Task <ActionResult> Workshops() { var model = new WorkshopsModel { Workshops = new List <WorkshopEntityModel>() }; var workshops = new WorkshopService().GetWorkshops().ToList(); var workshopTickets = await AppFactory.TicketService.Value.GetWorkshopsTicketsAsync(); foreach (var workshop in workshops) { var ticketsLeft = workshop.MaxTickets - workshopTickets.Count(x => x.WorkshopId == workshop.Id); if (ticketsLeft < 0) { ticketsLeft = 0; } model.Workshops.Add(new WorkshopEntityModel { Workshop = workshop, TicketsLeft = ticketsLeft, ShowSpeakerInfo = true }); } return(View(model)); }
static ServiceHelper() { Workshop = new WorkshopService(); Student = new StudentService(); Booking = new BookingService(); Misc = new MiscService(); Task.Factory.StartNew(HelpsService.Purge); }
public WorkshopType(WorkshopService workshopService) { Field(o => o.Id); Field(o => o.Name); Field <ListGraphType <ExerciseType>, IEnumerable <Exercise> >() .Name("exercises") .Resolve(ctx => workshopService.GetExercisesForWorkshopIdAsync(ctx.Source.Id)); }
static Services() { helpsDatabase.InitDatabase(); Auth = new AuthService(); Student = new StudentService(); Workshop = new WorkshopService(); Notification = new NotificationService(); Session = new SessionService(); Task.Factory.StartNew(HelpsService.Purge); }
public Task Invoke(HttpContext httpContext, WorkshopService service) { try { HomeViewModel model; if (!memoryCache.TryGetValue(cacheKey, out model)) { model = service.GetHomeViewModel(); memoryCache.Set(cacheKey, model, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(5))); } } catch (Exception ex) { } return(requestDelegate(httpContext)); }
public async Task <ActionResult> SpeakerEntity(string id) { var model = new SpeakerEntityModel(); model.Speaker = new SpeakerService().GetSpeaker(id); if (model.Speaker == null) { return(RedirectToAction("Index")); } var workshops = new WorkshopService() .GetWorkshops() .Where(x => x.Speaker.Id.Equals(model.Speaker.Id, StringComparison.InvariantCultureIgnoreCase)) .ToList(); model.Workshops = new List <WorkshopEntityModel>(); foreach (var workshop in workshops) { var ticketsLeft = workshop.MaxTickets - (await AppFactory.TicketService.Value.GetWorkshopTicketsAsync(workshop.Id)).Count; if (ticketsLeft < 0) { ticketsLeft = 0; } model.Workshops.Add(new WorkshopEntityModel { Workshop = workshop, TicketsLeft = ticketsLeft, ShowSpeakerInfo = false }); } model.Topics = new TopicService() .GetTopics() .Where(x => x.Speaker.Id != null) // ??? .Where(x => x.Speaker.Id.Equals(model.Speaker.Id, StringComparison.InvariantCultureIgnoreCase)) .OrderBy(x => x.Timetable.TimeStart) .ToList(); return(View(model)); }
public DeleteWorkshopTests() { _mocker = new MockerFactory(); _sut = new WorkshopService(workshopRepoMock.Object, _mocker.Context.Object, _mocker.Mapper.Object); }
public SchemaQuery(ExerciseService exercises, TrainingScheduleService trainingScheduleService, WorkshopService workshopService, WorkoutService workoutService, JourneyService journeyService) { Name = "Query"; Field <ListGraphType <ExerciseType> >( "exercises", resolve: context => exercises.GetExercisesAsync() ); Field <ListGraphType <TrainingScheduleType> >( "trainingSchedules", resolve: context => trainingScheduleService.GetTrainingSchedulesAsync() ); Field <ListGraphType <WorkshopType> >( "workshops", resolve: context => workshopService.GetWorkshopsAsync() ); Field <ListGraphType <WorkoutType> >( "workouts", resolve: context => workoutService.GetWorkoutsAsync() ); Field <ListGraphType <JourneyType> >( "journeys", resolve: context => journeyService.GetJourneysAsync() ); FieldAsync <ExerciseType>( "exercise", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id" }), resolve: async context => { return(await context.TryAsyncResolve( async c => await exercises.GetExerciseByIdAsync(c.GetArgument <int>("id")) )); } ); FieldAsync <JourneyType>( "journey", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id" }), resolve: async context => { return(await context.TryAsyncResolve( async c => await journeyService.GetJourneyByIdAsync(c.GetArgument <int>("id")) )); } ); FieldAsync <WorkoutType>( "workout", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id" }), resolve: async context => { return(await context.TryAsyncResolve( async c => await workoutService.GetWorkoutAsync(c.GetArgument <int>("id")) )); } ); }