Exemplo n.º 1
0
        /// <summary>
        /// Desc : Update Status
        /// </summary>
        /// <param name="status"></param>
        public bool AddWhatIsInYourMind(string status)
        {
            try
            {
                Utils.driver.FindElement(By.LinkText("Home")).Click();
                StatusInput.DoClick();
                StatusInput.SendChar(status);

                if (EmojiButton.Displayed)
                {
                    EmojiButton.Click();
                }

                EmojiType.Click();
                StatusInput.Click();
                PostButton.Click();
                System.Threading.Thread.Sleep(3000);
                if (Utils.driver.FindElements(By.XPath("//p[contains(text(),'" + status + "')]")).Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Status(StatusInput input)
        {
            var paymentViewModel = new PaymentViewModel() // TODO[mk] add validation
            {
                StatusInput = input,
            };

            if (!ModelState.IsValid)
            {
                return(View("Index", paymentViewModel));
            }

            var gateStatusRequest = new GateStatusRequest()
            {
                Session = input.Session,
                TransId = input.TransId,
            };

            try
            {
                paymentViewModel.GateStatusResponse = await m_Gate.Status(gateStatusRequest).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                m_Logger.Error(e.Message, e);
                paymentViewModel.ExceptionMessage = e.Message;
            }

            return(View("Index", paymentViewModel));
        }
Exemplo n.º 3
0
        public async Task <StatusOutput> AlterarStatus(StatusInput statusInput, CancellationToken cancellationToken)
        {
            return(await Task.Run(() =>
            {
                StatusOutput statusOutput = new StatusOutput();
                statusOutput.Pedido = statusInput.Pedido;

                Pedido pedido = PedidoRepository.GetById(statusInput.Pedido);
                if (pedido == null)
                {
                    pedido = new Pedido();
                }

                pedido.AlterarStatus(statusInput.Status, statusInput.ItensAprovados, statusInput.ValorAprovado);
                statusOutput.Status = pedido.GetStatusDetalhado();
                return statusOutput;
            }, cancellationToken));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Desc : Update Status
        /// </summary>
        /// <param name="status"></param>
        public bool AddWhatIsInYourMind(string status)
        {
            try
            {
                Utils.driver.FindElement(By.LinkText("Home")).Click();

                var textArea = Utils.driver.FindElements(By.XPath("//textarea[contains(@title,'Write something here')]"));
                if (textArea.Count > 0)
                {
                    textArea[0].Click();
                }
                else
                {
                    StatusInput.DoClick();
                }

                StatusInput.SendChar(status);

                if (EmojiButton.Displayed)
                {
                    EmojiButton.Click();
                }

                EmojiType.Click();
                StatusInput.Click();
                PostButton.Click();
                System.Threading.Thread.Sleep(3000);
                if (Utils.driver.FindElements(By.XPath("//p[contains(text(),'" + status + "')]")).Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                return(false);
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult> SetCurrentStatus(StatusInput statusInput, CancellationToken cancellationToken)
        {
            if (this.ModelState.IsValid)
            {
                try
                {
                    ActionLog log = null;
                    if (statusInput.Rto == 0)
                    {
                        log = await _actionLogsService.SetUserActionAsync(UserId, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Not, cancellationToken);
                    }
                    else if (statusInput.Dtp == 0)
                    {
                        log = await _actionLogsService.SetUserActionAsync(UserId, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto, statusInput.Not, cancellationToken);
                    }
                    else
                    {
                        log = await _actionLogsService.SetUserActionAsync(UserId, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto, statusInput.Dtp, statusInput.Not, cancellationToken);
                    }

                    //OutboundEventProvider.PersonnelStatusChangedTopicHandler handler = new OutboundEventProvider.PersonnelStatusChangedTopicHandler();
                    //await handler.Handle(new UserStatusEvent() { DepartmentId = DepartmentId, Status = log });
                    _eventAggregator.SendMessage <UserStatusEvent>(new UserStatusEvent()
                    {
                        DepartmentId = DepartmentId, Status = log
                    });

                    return(CreatedAtAction(nameof(SetCurrentStatus), new { id = log.ActionLogId }, log));
                }
                catch (Exception ex)
                {
                    Logging.LogException(ex);
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Exemplo n.º 6
0
        public HttpResponseMessage SetCurrentStatus(StatusInput statusInput)
        {
            if (this.ModelState.IsValid)
            {
                try
                {
                    ActionLog log = null;
                    if (statusInput.Rto == 0)
                    {
                        log = _actionLogsService.SetUserAction(UserId, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Not);
                    }
                    else if (statusInput.Dtp == 0)
                    {
                        log = _actionLogsService.SetUserAction(UserId, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto, statusInput.Not);
                    }
                    else
                    {
                        log = _actionLogsService.SetUserAction(UserId, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto, statusInput.Dtp, statusInput.Not);
                    }

                    OutboundEventProvider.PersonnelStatusChangedTopicHandler handler = new OutboundEventProvider.PersonnelStatusChangedTopicHandler();
                    handler.Handle(new UserStatusEvent()
                    {
                        DepartmentId = DepartmentId, Status = log
                    });

                    return(Request.CreateResponse(HttpStatusCode.Created));
                }
                catch (Exception ex)
                {
                    Logging.LogException(ex);
                    throw HttpStatusCode.InternalServerError.AsException();
                }
            }

            throw HttpStatusCode.BadRequest.AsException();
        }
Exemplo n.º 7
0
        public async Task <ActionResult> PostStatusForUser(StatusInput statusInput)
        {
            if (this.ModelState.IsValid)
            {
                try
                {
                    var userToSetStatusFor = await _departmentsService.GetDepartmentMemberAsync(statusInput.Uid, DepartmentId);

                    if (userToSetStatusFor == null)
                    {
                        return(NotFound());
                    }

                    if (!await _authorizationService.IsUserValidWithinLimitsAsync(statusInput.Uid, DepartmentId))
                    {
                        return(Unauthorized());
                    }

                    if (!await _authorizationService.IsUserValidWithinLimitsAsync(userToSetStatusFor.UserId, DepartmentId))
                    {
                        return(Unauthorized());
                    }

                    if (DepartmentId != userToSetStatusFor.DepartmentId)
                    {
                        return(Unauthorized());
                    }

                    // TODO: We need to check here if the user is a department admin, or the admin that the user is a part of

                    ActionLog log = null;
                    if (statusInput.Rto == 0)
                    {
                        log = await _actionLogsService.SetUserActionAsync(statusInput.Uid, DepartmentId, statusInput.Typ, statusInput.Geo);
                    }
                    else if (statusInput.Dtp == 0)
                    {
                        log = await _actionLogsService.SetUserActionAsync(statusInput.Uid, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto, statusInput.Not);
                    }
                    else
                    {
                        log = await _actionLogsService.SetUserActionAsync(statusInput.Uid, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto);
                    }

                    //OutboundEventProvider.PersonnelStatusChangedTopicHandler handler = new OutboundEventProvider.PersonnelStatusChangedTopicHandler();
                    //await handler.Handle(new UserStatusEvent() { DepartmentId = DepartmentId, Status = log });
                    _eventAggregator.SendMessage <UserStatusEvent>(new UserStatusEvent()
                    {
                        DepartmentId = DepartmentId, Status = log
                    });

                    return(CreatedAtAction(nameof(SetStatusForUser), new { id = log.ActionLogId }, log));
                }
                catch (Exception ex)
                {
                    Logging.LogException(ex);
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Exemplo n.º 8
0
        public HttpResponseMessage PostStatusForUser(StatusInput statusInput)
        {
            if (this.ModelState.IsValid)
            {
                try
                {
                    var userToSetStatusFor = _departmentsService.GetDepartmentMember(statusInput.Uid, DepartmentId);

                    if (userToSetStatusFor == null)
                    {
                        throw HttpStatusCode.NotFound.AsException();
                    }

                    if (!_authorizationService.IsUserValidWithinLimits(statusInput.Uid, DepartmentId))
                    {
                        throw HttpStatusCode.Unauthorized.AsException();
                    }

                    if (!_authorizationService.IsUserValidWithinLimits(userToSetStatusFor.UserId, DepartmentId))
                    {
                        throw HttpStatusCode.Unauthorized.AsException();
                    }

                    if (DepartmentId != userToSetStatusFor.DepartmentId)
                    {
                        throw HttpStatusCode.Unauthorized.AsException();
                    }

                    // TODO: We need to check here if the user is a department admin, or the admin that the user is a part of

                    ActionLog log = null;
                    if (statusInput.Rto == 0)
                    {
                        log = _actionLogsService.SetUserAction(statusInput.Uid, DepartmentId, statusInput.Typ, statusInput.Geo);
                    }
                    else if (statusInput.Dtp == 0)
                    {
                        log = _actionLogsService.SetUserAction(statusInput.Uid, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto, statusInput.Not);
                    }
                    else
                    {
                        log = _actionLogsService.SetUserAction(statusInput.Uid, DepartmentId, statusInput.Typ, statusInput.Geo, statusInput.Rto);
                    }

                    OutboundEventProvider.PersonnelStatusChangedTopicHandler handler = new OutboundEventProvider.PersonnelStatusChangedTopicHandler();
                    handler.Handle(new UserStatusEvent()
                    {
                        DepartmentId = DepartmentId, Status = log
                    });

                    var response = Request.CreateResponse(HttpStatusCode.Created);
                    response.Headers.Add("Access-Control-Allow-Origin", "*");
                    response.Headers.Add("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
                    return(response);
                }
                catch (Exception ex)
                {
                    Logging.LogException(ex);
                    throw HttpStatusCode.InternalServerError.AsException();
                }
            }

            throw HttpStatusCode.BadRequest.AsException();
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create(StatusInput statusInput, CancellationToken cancellationToken)
        {
            var statusOutput = await PedidoService.AlterarStatus(statusInput, cancellationToken);

            return(Ok(statusOutput));
        }