示例#1
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            try
            {
                var currentUser = await GetCurrentUser();

                AlertBLL bll = new AlertBLL(_unit);

                bool isAdmin = await AppUserManager.IsInRoleAsync(currentUser.Id, "Admin");

                if (isAdmin)
                {
                    bll.Delete(id);
                }
                else
                {
                    var w = bll.GetByID(id);

                    if (w.Owner == currentUser.Id)
                    {
                        bll.Delete(id);
                    }
                    else
                    {
                        BadRequest("You don't have permission to delete this alert.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }
            return(Ok());
        }
        public void Test_VerifyAlert()
        {
            AlertBLL bll = new AlertBLL(_unit);

            Alert a = bll.GetByID(9);

            var result = bll.VerifyAlert(a);
        }
        public void Test_Create()
        {
            AlertBLL bll = new AlertBLL(_unit);

            Alert b = new Alert
            {
                Formula      = "test formula",
                Message      = "alert trigerred",
                ModifiedDate = DateTime.Now,
                Owner        = "2b658482-6a38-4ed3-b356-77fe9b1569f1",
                ShareId      = 1585
            };

            bll.Create(b);
        }
示例#4
0
        public async Task <IHttpActionResult> Get(int?zoneId)
        {
            List <Alert> nlist = null;

            try
            {
                var currentUser = await base.GetCurrentUser();

                AlertBLL bll = new AlertBLL(_unit);

                nlist = bll.GetAlertListByZone(currentUser.Id, zoneId);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(nlist));
        }
        public async Task <IHttpActionResult> SearchAlert(int tradingDate, bool force, int?zoneId)
        {
            List <OutStockSearchResult> nlist = null;

            try
            {
                var currentUser = await base.GetCurrentUser();

                AlertBLL bll = new AlertBLL(_unit);

                nlist = bll.SearchAlert(currentUser.Id, tradingDate, force, zoneId);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(nlist));
        }
        public void Test_SearchAlert()
        {
            AlertBLL bll = new AlertBLL(_unit);

            var result = bll.SearchAlert("2b658482-6a38-4ed3-b356-77fe9b1569f1", 20160902, false, null);
        }
        public void Test_ProcessAlertsFull()
        {
            AlertBLL bll = new AlertBLL(_unit);

            bll.ProcessAlertsFull(true);
        }