Esempio n. 1
0
 public IHttpActionResult Query([FromUri] PlanQueryDTO planQuery)
 {
     using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
     {
         var planResult = _plan.GetForUser(
             uow,
             _security.GetCurrentAccount(uow),
             planQuery,
             _security.IsCurrentUserHasRole(Roles.Admin)
             );
         return(Ok(planResult));
     }
 }
Esempio n. 2
0
        public IHttpActionResult Get()
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                IList <ContainerDO> curContainer = _containerService
                                                   .GetByFr8Account(
                    uow,
                    _security.GetCurrentAccount(uow),
                    _security.IsCurrentUserHasRole(Roles.Admin),
                    null
                    );

                if (curContainer.Any())
                {
                    return(Ok(curContainer.Select(Mapper.Map <ContainerDTO>)));
                }
                return(Ok());
            }
        }
        public IHttpActionResult Details(int id)
        {
            FileDTO fileDto = null;

            if (_security.IsCurrentUserHasRole(Roles.Admin))
            {
                fileDto = Mapper.Map <FileDTO>(_fileService.GetFileByAdmin(id));
            }
            else
            {
                string userId;

                using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
                {
                    userId = _security.GetCurrentAccount(uow).Id;
                }

                fileDto = Mapper.Map <FileDTO>(_fileService.GetFile(id, userId));
            }

            return(Ok(fileDto));
        }
Esempio n. 4
0
        public IList <FactDO> GetByObjectId(IUnitOfWork unitOfWork, string id)
        {
            //here we should determine type of ObjectId, to look at it`s owner in appropriate table
            //but it is non trivial action so for now select facts where userid is the same as fr8UserId

            if (_securityServices.IsCurrentUserHasRole(Data.States.Roles.Admin))
            {
                return
                    (unitOfWork.FactRepository.GetQuery().Where(
                         fact =>
                         fact.ObjectId == id
                         ).ToList());
            }
            else
            {
                var fr8UserId = _securityServices.GetCurrentAccount(unitOfWork).Id;
                return
                    (unitOfWork.FactRepository.GetQuery().Where(
                         fact =>
                         fact.ObjectId == id &&
                         fact.Fr8UserId.Equals(fr8UserId, StringComparison.InvariantCultureIgnoreCase))
                     .ToList());
            }
        }