Example #1
0
        public async Task <Lacteo> LacteoById([Service] IngredientesRepository repo, [Service] ITopicEventSender eventSender, int id)
        {
            Lacteo lacteoId = repo.GetLacteoId(id);
            await eventSender.SendAsync("RetornaLacteo", lacteoId);

            return(lacteoId);
        }
Example #2
0
        public async Task ModificarHarinaCereal([Service] IngredientesRepository repo,
                                                [Service] ITopicEventSender eventSender, int idCereal, String nombre, bool alergeno)
        {
            HarinaCereal editHarinaCereal = await repo.ModificarHarinaCerealAsync(idCereal, nombre, alergeno);

            await eventSender.SendAsync("Editado Harina/Cereal", editHarinaCereal);
        }
Example #3
0
 public string WriteOnExplicit(
     string message,
     [Service] ITopicEventSender eventSender)
 {
     eventSender.SendAsync("explicit", message);
     return(message);
 }
Example #4
0
 public string WriteFixedMessage(
     string message,
     [Service] ITopicEventSender eventSender)
 {
     eventSender.SendAsync("Fixed", message);
     return(message);
 }
Example #5
0
 public string WriteOnInferTopic(
     string message,
     [Service] ITopicEventSender eventSender)
 {
     eventSender.SendAsync("OnInferTopic", message);
     return(message);
 }
Example #6
0
        //MODIFICAR MUTATION
        public async Task ModificarIngredientes([Service] PlatosRepository repo,
                                                [Service] ITopicEventSender eventSender, int idPlato, int idCarne, int idVerdura, int idHarina, int idLacteo)
        {
            PlatoIngrediente editplatoIngrediente = await repo.ModificarIngredientesPlatoAsync(idPlato, idCarne, idVerdura, idHarina, idLacteo);

            await eventSender.SendAsync("Ingredientes plato modificado", editplatoIngrediente);
        }
Example #7
0
        public async Task <AddProductPayload> AddProductAsync(
            AddProductInput input,
            [ScopedService] ApplicationDbContext context,
            [Service] ITopicEventSender eventSender)
        {
            var product = new Product
            {
                Name        = input.name,
                Description = input.description,
                UOM         = input.uom,
                Status      = input.status,
                BrandId     = input.brandId,
                CategoryId  = input.categoryId
            };

            await context.Products.AddAsync(product);

            await context.SaveChangesAsync();

            await eventSender.SendAsync(
                nameof(ProductsSubscription.OnProductCreatedAsync),
                product.Id
                );

            return(new AddProductPayload(product));
        }
        public async Task <Account> CreateAccount([Service] ITopicEventSender eventSender,
                                                  CancellationToken cancellationToken,
                                                  Account account)
        {
            if (account == null)
            {
                throw new QueryException(
                          ErrorBuilder.New()
                          .SetMessage("Please provide valid data")
                          .SetCode("ACCOUNT_NULL")
                          .Build());
            }

            var result = await _repository.CreateAccount(account);

            if (!string.IsNullOrEmpty(result.ErrorMessage))
            {
                throw new QueryException(
                          ErrorBuilder.New()
                          .SetMessage(result.ErrorMessage)
                          .SetCode("OWNER_ID_INVALID")
                          .Build());
            }

            await eventSender.SendAsync("Created", result.ModelData, cancellationToken);

            return(result.ModelData);
        }
Example #9
0
        public async Task <UpdatePostPayload> UpdatePostAsync(UpdatePostInput input,
                                                              [ScopedService] ApiContext context,
                                                              [Service] ITopicEventSender eventSender)
        {
            Post post = await context.Posts.Include(p => p.Tags)
                        .SingleOrDefaultAsync(p => p.Id == input.Id)
                        .ConfigureAwait(false);

            if (post == null)
            {
                return(new UpdatePostPayload(new ApiError("POST_NOT_FOUND", "Post not found.")));
            }

            Post postWithTitle = await context.Posts.FirstOrDefaultAsync(p => p.Title == input.Title)
                                 .ConfigureAwait(false);

            if (postWithTitle != null && postWithTitle.Id != post.Id)
            {
                return(new UpdatePostPayload(new ApiError("POST_WITH_TITLE_EXISTS", "A post with that title already exists.")));
            }

            await ApplyUpdatedValuesToPost(post, input, context).ConfigureAwait(false);

            await context.SaveChangesAsync()
            .ConfigureAwait(false);

            await eventSender.SendAsync(nameof(PostSubscriptions.OnPostUpdatedAsync), post.Id)
            .ConfigureAwait(false);

            return(new UpdatePostPayload(post));
        }
        public async Task <CheckInAttendeePayload> CheckInAttendeeAsync(
            CheckInAttendeeInput input,
            [ScopedService] ApplicationDbContext context,
            [Service] ITopicEventSender eventSender,
            CancellationToken cancellationToken)
        {
            Attendee attendee = await context.Attendees.FirstOrDefaultAsync(
                t => t.Id == input.AttendeeId, cancellationToken);

            if (attendee is null)
            {
                return(new CheckInAttendeePayload(
                           new UserError("Attendee not found.", "ATTENDEE_NOT_FOUND")));
            }

            attendee.SessionsAttendees.Add(
                new SessionAttendee
            {
                SessionId = input.SessionId
            });

            await context.SaveChangesAsync(cancellationToken);

            await eventSender.SendAsync(
                "OnAttendeeCheckedIn_" + input.SessionId,
                input.AttendeeId,
                cancellationToken);

            return(new CheckInAttendeePayload(attendee, input.SessionId));
        }
Example #11
0
 public string WriteSysMessage(
     string message,
     [Service] ITopicEventSender eventSender)
 {
     eventSender.SendAsync("OnSysMessage", message);
     return(message);
 }
Example #12
0
 public SmsController(ILogger <SmsController> logger, ICloudStorage storageClient, IConfiguration configuration, TenantFileContext context, [Service] ITopicEventSender eventSender)
 {
     this.eventSender   = eventSender;
     this.logger        = logger;
     this.storageClient = storageClient;
     this.context       = context;
 }
Example #13
0
        public async Task ModificarVerduraFruta([Service] IngredientesRepository repo,
                                                [Service] ITopicEventSender eventSender, int idVerdura, String nombre, bool alergeno)
        {
            VerduraFruta editVerduraFruta = await repo.ModificarVerduraFrutaAsync(idVerdura, nombre, alergeno);

            await eventSender.SendAsync("Editado Verdura/Fruta", editVerduraFruta);
        }
Example #14
0
        public async Task <Plato> UnPlato([Service] PlatosRepository repo, [Service] ITopicEventSender eventSender, int id)
        {
            Plato platoPorId = repo.GetPlatoId(id);
            await eventSender.SendAsync("RetornaPlato", platoPorId);

            return(platoPorId);
        }
Example #15
0
        public async Task <ScheduleSessionPayload> ScheduleSessionAsync(
            ScheduleSessionInput input,
            [ScopedService] ApplicationDbContext context,
            [Service] ITopicEventSender eventSender)
        {
            if (input.EndTime < input.StartTime)
            {
                return(new ScheduleSessionPayload(
                           new UserError("endTime has to be larger than startTime.", "END_TIME_INVALID")));
            }

            Session session = await context.Sessions.FindAsync(input.SessionId);

            int?initialTrackId = session.TrackId;

            if (session is null)
            {
                return(new ScheduleSessionPayload(
                           new UserError("Session not found.", "SESSION_NOT_FOUND")));
            }

            session.TrackId   = input.TrackId;
            session.StartTime = input.StartTime;
            session.EndTime   = input.EndTime;

            await context.SaveChangesAsync();

            await eventSender.SendAsync(
                nameof(SessionSubscription.OnSessionScheduledAsync),
                session.Id);

            return(new ScheduleSessionPayload(session));
        }
Example #16
0
        public async Task ModificarCarnePescado([Service] IngredientesRepository repo,
                                                [Service] ITopicEventSender eventSender, int idCarne, String nombre, bool alergeno)
        {
            CarnePescado editCarnePescado = await repo.ModificarCarnePescadoAsync(idCarne, nombre, alergeno);

            await eventSender.SendAsync("Editado Carne/Pescado", editCarnePescado);
        }
Example #17
0
        public async Task CrearLacteo([Service] IngredientesRepository repo,
                                      [Service] ITopicEventSender eventSender, int idLacteo, String nombre, bool alergeno)
        {
            Lacteo newLacteo = await repo.CrearLacteoAsync(idLacteo, nombre, alergeno);

            await eventSender.SendAsync("Guardado Lacteo", newLacteo);
        }
Example #18
0
        public async Task CrearHarinaCereal([Service] IngredientesRepository repo,
                                            [Service] ITopicEventSender eventSender, int idCereal, String nombre, bool alergeno)
        {
            HarinaCereal newHarinaCereal = await repo.CrearHarinaCerealAsync(idCereal, nombre, alergeno);

            await eventSender.SendAsync("Guardado Harina/Cereal", newHarinaCereal);
        }
Example #19
0
        public async Task CrearVerduraFruta([Service] IngredientesRepository repo,
                                            [Service] ITopicEventSender eventSender, int idVerdura, String nombre, bool alergeno)
        {
            VerduraFruta newVerduraFruta = await repo.CrearVerduraFrutaAsync(idVerdura, nombre, alergeno);

            await eventSender.SendAsync("Guardado Verdura/Fruta", newVerduraFruta);
        }
Example #20
0
        public async Task CrearCarnePescado([Service] IngredientesRepository repo,
                                            [Service] ITopicEventSender eventSender, int idCarne, String nombre, bool alergeno)
        {
            CarnePescado newCarnePescado = await repo.CrearCarnePescadoAsync(idCarne, nombre, alergeno);

            await eventSender.SendAsync("Guardado Carne/Pescado", newCarnePescado);
        }
Example #21
0
        public async Task <Employee> GetEmployeeById([Service] EmployeeRepository employeeRepository,
                                                     [Service] ITopicEventSender eventSender, int id)
        {
            Employee gottenEmployee = employeeRepository.GetEmployeeById(id);
            await eventSender.SendAsync("ReturnedEmployee", gottenEmployee);

            return(gottenEmployee);
        }
Example #22
0
        public async Task <Book> GetEmployeeById([Service] BookRepository bookRepository,
                                                 [Service] ITopicEventSender eventSender, int id)
        {
            var gottenBook = bookRepository.GetBookById(id);
            await eventSender.SendAsync("ReturnedBook", gottenBook);

            return(gottenBook);
        }
Example #23
0
        public async Task <Student> GetStudentById([Service] StudentRepository studentRepository,
                                                   [Service] ITopicEventSender eventSender, int id)
        {
            Student gottenStudent = studentRepository.GetStudentById(id);
            await eventSender.SendAsync("ReturnedStudent", gottenStudent);

            return(gottenStudent);
        }
Example #24
0
 public string WriteMessage(
     string userId,
     string message,
     [Service] ITopicEventSender eventSender)
 {
     eventSender.SendAsync(userId, message);
     return(message);
 }
        public async Task <Subject> CreateSubject(Subject subject, [Service] ITopicEventSender eventSender)
        {
            _subjectService.Insert(subject);

            await eventSender.SendAsync("SubjectCreated", subject);

            return(subject);
        }
Example #26
0
 public bool WriteBoolean(
     string userId,
     bool message,
     [Service] ITopicEventSender eventSender)
 {
     eventSender.SendAsync(userId, message);
     return(message);
 }
        /// <summary>
        /// Creates a review for a given Star Wars episode.
        /// </summary>
        /// <param name="episode">The episode to review.</param>
        /// <param name="review">The review.</param>
        /// <param name="eventSender">The event sending service.</param>
        /// <returns>The created review.</returns>
        public async Task <Review> CreateReview(
            Episode episode, Review review,
            [Service] ITopicEventSender eventSender)
        {
            _repository.AddReview(episode, review);
            await eventSender.SendAsync(episode, review);

            return(review);
        }
Example #28
0
        public async Task <GeneratedService.ProductJson> GetProductAsync(
            [Service] ITopicEventSender eventSender, [Service] ProductClient service, CancellationToken cancellationToken, int id)
        {
            ProductJson product = await service.GetFullProductsByIdAsync(id, cancellationToken);

            await eventSender.SendAsync(nameof(SubscriptionObjectType.SubscribeProductGetDate), product, cancellationToken);

            return(product);
        }
Example #29
0
 /// <summary>
 /// Initializes a new instance of the UAClient class.
 /// </summary>
 public UAClient(IOutput output, XMLParser xmlParser, ITopicEventSender eventSender)
 {
     _eventSender   = eventSender;
     _xmlConfig     = xmlParser.OpcUaXmlFileRead("XmlConfig.xml");
     _output        = output;
     _configuration = CreateClientConfiguration();
     _tags          = new ObservableCollection <Tag>();
     ConnectAsync().Wait();
 }
Example #30
0
 public MutationResolver(
     IImmutableMapper <HumanInput, Human> humanInputToHumanMapper,
     IHumanRepository humanRepository,
     ITopicEventSender topicEventSender)
 {
     this.humanInputToHumanMapper = humanInputToHumanMapper;
     this.humanRepository         = humanRepository;
     this.topicEventSender        = topicEventSender;
 }