public Guid Create(ActionAndBenefitsDTO entityDTO)
        {
            ActionsAndBenefits action = CreateActionsAndBenefitsFromDTO(entityDTO);

            _actionAndBenefitsRepository.Create(action);
            return(action.IDAction);
        }
Esempio n. 2
0
 public IActionResult Add(ActionAndBenefitsDTO dto)
 {
     try
     {
         return(Ok(_actionAndBenefitsService.Create(dto)));
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
Esempio n. 3
0
        public override Task StartAsync(CancellationToken cancellationToken)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            connection = factory.CreateConnection();
            channel    = connection.CreateModel();
            channel.QueueDeclare(queue: "nina.queue",
                                 durable: false,
                                 exclusive: false,
                                 autoDelete: false,
                                 arguments: null);

            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, ea) =>
            {
                byte[] body                  = ea.Body.ToArray();
                string jsonMessage           = Encoding.UTF8.GetString(body);
                ActionAndBenefitsDTO message = JsonConvert.DeserializeObject <ActionAndBenefitsDTO>(jsonMessage);
                try
                {
                    _actionAndBenefitsService.Create(message);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            };
            channel.BasicConsume(queue: "nina.queue",
                                 autoAck: true,
                                 consumer: consumer);
            return(base.StartAsync(cancellationToken));
        }
 public void Update(ActionAndBenefitsDTO entityDTO, Guid id)
 {
     _actionAndBenefitsRepository.Update(CreateActionsAndBenefitsFromDTO(entityDTO));
 }
 public void Update(ActionAndBenefitsDTO entityDTO, Guid id, Boolean isApproved)
 {
     _actionAndBenefitsRepository.Update(CreateActionsAndBenefitsFromDTOWithIsApproved(entityDTO, id, isApproved));
 }
 private ActionsAndBenefits CreateActionsAndBenefitsFromDTO(ActionAndBenefitsDTO action, Guid?actionKey = null)
 => actionKey == null ? new ActionsAndBenefits(action.PharmacyName, action.ActionName, action.BeginDate, action.EndDate, action.OldCost, action.NewCost)
                 : new ActionsAndBenefits(actionKey.Value, action.PharmacyName, action.ActionName, action.BeginDate, action.EndDate, action.OldCost, action.NewCost, false);
 private ActionsAndBenefits CreateActionsAndBenefitsFromDTOWithIsApproved(ActionAndBenefitsDTO action, Guid?actionKey = null, Boolean?isApproved = false)
 => actionKey == null && isApproved == false ? new ActionsAndBenefits(action.PharmacyName, action.ActionName, action.BeginDate, action.EndDate, action.OldCost, action.NewCost)
                 : new ActionsAndBenefits(actionKey.Value, action.PharmacyName, action.ActionName, action.BeginDate, action.EndDate, action.OldCost, action.NewCost, isApproved.Value);