public void Test_Update()
        {
            WatchListBLL tbll = new WatchListBLL(_unit);

            var w = tbll.GetByID(1);

            w.IsSystem = true;

            tbll.Update(w);
        }
        public void Test_Create()
        {
            WatchListBLL tbll = new WatchListBLL(_unit);

            WatchList w = new WatchList
            {
                Name        = "SysWL - Long Term",
                Description = "Long Term Watch List",
                Owner       = "system"
            };

            tbll.Create(w);
        }
        public async Task <IHttpActionResult> Get(int id)
        {
            WatchList w = null;

            try
            {
                WatchListBLL bll = new WatchListBLL(_unit);

                w = bll.GetByID(id);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(w));
        }
        public async Task <IHttpActionResult> GetByZone(int?zoneId)
        {
            List <WatchList> wlist = null;

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

                WatchListBLL bll = new WatchListBLL(_unit);

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

            return(Ok(wlist));
        }
        public async Task <IHttpActionResult> Delete(int id)
        {
            try
            {
                var currentUser = await GetCurrentUser();

                WatchListBLL bll = new WatchListBLL(_unit);

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

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

                    if (!w.IsSystem && w.Owner == currentUser.Id)
                    {
                        bll.Delete(id);
                    }
                    else
                    {
                        BadRequest("You don't have permission to delete this watch list.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }


            return(Ok());
        }
 public void Test_GetWatchList()
 {
     WatchListBLL     tbll  = new WatchListBLL(_unit);
     List <WatchList> wlist = tbll.GetWatchList("2b658482-6a38-4ed3-b356-77fe9b1569f1");
 }
        public void Test_GetWatchListByShare()
        {
            WatchListBLL tbll = new WatchListBLL(_unit);

            var dlist = tbll.GetWatchListByShare(2433, "2b658482-6a38-4ed3-b356-77fe9b1569f1");
        }
        public void Test_GetWatchListDetail()
        {
            WatchListBLL tbll = new WatchListBLL(_unit);

            tbll.GetWatchListDetail(1, "2b658482-6a38-4ed3-b356-77fe9b1569f1");
        }
        public void Test_RemoveShareFromWatchList()
        {
            WatchListBLL tbll = new WatchListBLL(_unit);

            tbll.RemoveShareFromWatchList(1, "2b658482-6a38-4ed3-b356-77fe9b1569f1", "1,20,3,4,5");
        }
        public void Test_AddShareToWatchList()
        {
            WatchListBLL tbll = new WatchListBLL(_unit);

            tbll.AddShareToWatchList(1, "2b658482-6a38-4ed3-b356-77fe9b1569f1", "1");
        }