Exemple #1
0
        public string CreateDashboard(CreateDashboardDto dbDto, User user)
        {
            Dashboard dashEnt = new Dashboard
            {
                DashBoardGUID = CreateGUID.GetGUID(),
                Name          = dbDto.Name,
                Author        = user
            };

            _dashboardRepository.Add(dashEnt);//add után már benne van a Id érték
            _userDashRelRepository.Add(new UserDashboardRel {
                User = user, AuthoryLayer = (int)DashboardUserPermissions.CanModify, Dashboard = dashEnt
            });

            foreach (var rel in dbDto.Reports)
            {
                var report = _reportRepository.Get(rel.ReportGUID);
                if (report == null)
                {
                    continue;
                }
                _reportDashboardRel.Add(new ReportDashboardRel {
                    Dashboard = dashEnt, Report = report, Position = rel.Position
                });
            }
            return(dashEnt.DashBoardGUID);
        }
Exemple #2
0
        public string CreateReport(CreateReportDto report, User user)
        {
            var dbReport = new Report
            {
                Name       = report.Name,
                ReportGUID = CreateGUID.GetGUID(),
                Query      = _reportRepository.GetQuery(report.QueryGUID),
                Columns    = StringArraySerializer(report.Columns),
                Filter     = report.Filter,
                Sort       = JsonConvert.SerializeObject(report.Sort, Formatting.None),
                Rows       = report.Rows,
                Author     = user
            };

            _reportRepository.Add(dbReport);

            _userReportRel.Add(new ReportUserRel
            {
                Report       = dbReport,
                User         = user,
                AuthoryLayer = (int)ReportUserPermissions.CanModify
            });

            return(dbReport.ReportGUID);
        }
Exemple #3
0
        public IActionResult Register([FromBody] RegisterDto register)
        {
            try
            {
                if (register == null)
                {
                    throw new BasicException("Wrong data syntax.");
                }
                if (!ModelState.IsValid)
                {
                    BadRequest(ModelState);
                }

                var user = _userRepository.GetAll().FirstOrDefault(x => x.EmailAddress.Equals(register.EmailAddress));
                if (user != null)
                {
                    throw new BasicException("Emailaddress is reserved.");
                }

                _userRepository.Add(
                    new User
                {
                    Name         = register.Name,
                    UserGUID     = CreateGUID.GetGUID(),
                    EmailAddress = register.EmailAddress,
                    Password     = GetHashedPaswd(register.Password)
                });

                return(Login(new CredentialDto {
                    EmailAddress = register.EmailAddress, Password = register.Password
                }));
            }
            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());
            }
        }