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

                IdeaBLL bll = new IdeaBLL(_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 idea.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }
            return(Ok());
        }
示例#2
0
        public void Test_Create()
        {
            IdeaBLL bll = new IdeaBLL(_unit);

            Idea b = new Idea
            {
                Owner    = "2b658482-6a38-4ed3-b356-77fe9b1569f1",
                Content  = "test content",
                Topic    = "test topic",
                Type     = IdeaType.Strategy_Sell.ToString(),
                Status   = "Open",
                Created  = DateTime.Now,
                Modified = DateTime.Now
            };

            bll.Create(b);

            b = new Idea
            {
                Owner    = "2b658482-6a38-4ed3-b356-77fe9b1569f1",
                Content  = "test content222",
                Topic    = "test topic 222",
                Type     = IdeaType.Strategy_Buy.ToString(),
                Status   = "Open",
                Created  = DateTime.Now,
                Modified = DateTime.Now
            };

            bll.Create(b);
        }
示例#3
0
        public void Test_GetList()
        {
            IdeaBLL bll   = new IdeaBLL(_unit);
            string  owner = "2b658482-6a38-4ed3-b356-77fe9b1569f1";

            var jList = bll.GetList(owner);


            //jList = bll.GetListByZone(owner, zoneId);
        }
示例#4
0
        public async Task <IHttpActionResult> Get(int id)
        {
            Idea j = null;

            try
            {
                IdeaBLL bll = new IdeaBLL(_unit);

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

            return(Ok(j));
        }
示例#5
0
        public async Task <IHttpActionResult> Get()
        {
            List <Idea> slist = null;

            try
            {
                var currentUser = await GetCurrentUser();

                IdeaBLL bll = new IdeaBLL(_unit);

                slist = bll.GetList(currentUser.Id).ToList();
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(slist));
        }