Ejemplo n.º 1
0
        public void Test_Create()
        {
            JourneyBLL bll = new JourneyBLL(_unit);

            Journey b = new Journey
            {
                Owner    = "2b658482-6a38-4ed3-b356-77fe9b1569f1",
                Content  = "test content",
                StartDay = "20160816",

                Status   = "Open",
                Created  = DateTime.Now,
                Modified = DateTime.Now
            };

            bll.Create(b);

            b = new Journey
            {
                Owner    = "2b658482-6a38-4ed3-b356-77fe9b1569f1",
                Content  = "test content222",
                StartDay = "20160817",
                ZoneId   = 2,
                Status   = "Open",
                Created  = DateTime.Now,
                Modified = DateTime.Now
            };

            bll.Create(b);
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            try
            {
                var currentUser = await GetCurrentUser();

                JourneyBLL bll = new JourneyBLL(_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 journey.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }
            return(Ok());
        }
Ejemplo n.º 3
0
        public void Test_GetListByZone()
        {
            JourneyBLL bll    = new JourneyBLL(_unit);
            string     owner  = "2b658482-6a38-4ed3-b356-77fe9b1569f1";
            int?       zoneId = 2;

            var jList = bll.GetListByZone(owner, null);


            jList = bll.GetListByZone(owner, zoneId);
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> Get(int id)
        {
            Journey j = null;

            try
            {
                JourneyBLL bll = new JourneyBLL(_unit);

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

            return(Ok(j));
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> Get(int?zoneId)
        {
            List <Journey> slist = null;

            try
            {
                var currentUser = await GetCurrentUser();

                JourneyBLL bll = new JourneyBLL(_unit);

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

            return(Ok(slist));
        }