コード例 #1
0
        public bool Create(CreateReportUserDto reportUserRel)
        {
            IsExistUserAndReport(out User user, out Report report, reportUserRel.UserGUID, reportUserRel.ReportGUID);
            if (IsExistRel(user.Id, report.Id) != null)
            {
                throw new BasicException("Already exists value with this paramterers.");
            }

            _reportUserRelRepository.Add(new ReportUserRel {
                Report = report, User = user, AuthoryLayer = reportUserRel.Permission
            });
            return(true);
        }
コード例 #2
0
        public IActionResult Create([FromBody] CreateReportUserDto reportUserRel)
        {
            try
            {
                if (reportUserRel == null)
                {
                    throw new BasicException("Wrong body format.");
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _manager.Create(reportUserRel);
                return(Created(string.Empty, null));
            }
            catch (BasicException ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex.Message));
            }
            catch (NotFoundException ex)
            {
                _logger.LogError(ex.Message);
                return(NotFound(ex.Message));
            }
            catch (PermissionException ex)
            {
                _logger.LogError(ex.Message);
                return(Unauthorized());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest());
            }
        }