public async Task <ActionResult> GetProtocol(int protocolId)
        {
            var protocol = await _protocolsService.GetProtocolByIdAsync(protocolId);

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

            if (protocol.DepartmentId != DepartmentId)
            {
                return(Unauthorized());
            }

            var result = ProtocolResult.Convert(protocol);


            return(Ok(JsonConvert.SerializeObject(result)));
        }
Exemple #2
0
        public async Task <bool> CanUserModifyProtocolAsync(string userId, int protocolId)
        {
            var department = await _departmentsService.GetDepartmentByUserIdAsync(userId);

            var protocol = await _protocolsService.GetProtocolByIdAsync(protocolId);

            if (department == null || protocol == null)
            {
                return(false);
            }

            if (protocol.DepartmentId != department.DepartmentId)
            {
                return(false);
            }

            if (department.IsUserAnAdmin(userId))
            {
                return(true);
            }

            return(false);
        }
Exemple #3
0
        public async Task <IActionResult> GetProtocol(int id)
        {
            var template = await _protocolsService.GetProtocolByIdAsync(id);

            return(Json(template));
        }