Exemplo n.º 1
0
        private async Task <(Lab lab, bool isLabManager)> GetLab(long labId)
        {
            var lab = await LabsDao.Read(this, labId);

            var isLabManager = IsLabManager(lab);

            return(lab, isLabManager);
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> Read(long labId)
        {
            var(_, isLabManager) = await GetLab(labId);

            var result = await LabsDao.Read(this, labId);

            if (result == null)
            {
                return(NotFound());
            }

            return(JsonWithPermissions(result, User.IsPrivileged(), isLabManager, User.IsAdmin()));
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> Update(long labId, LabsEditViewModel model)
        {
            var(_, isLabManager) = await GetLab(labId);

            var lab = await LabsDao.Read(this, labId);

            if (lab == null)
            {
                return(NotFound());
            }

            var result = await LabsDao.Update(this, lab, model);

            return(JsonWithPermissions(result, User.IsPrivileged(), isLabManager, User.IsAdmin()));
        }