public QuestionModel Create(AnsweredQuestion question, AppContext context)
 {
     return(new QuestionModel()
     {
         Id = question.Id,
         HeuristicTitle = question.HeuristicTitle,
         HeuristicText = question.HeuristicText,
     });
 }
 public VersionModel Create(Infrastructure.Database.Entities.Version verzija, AppContext homeContext)
 {
     return(new VersionModel()
     {
         Id = verzija.Id,
         Date = verzija.Date,
         VersionName = verzija.VersionName
     });
 }
 internal GroupModel CreateWithCheckedFalse(UserGroup x, AppContext appContext)
 {
     return(new GroupModel()
     {
         Id = x.Id,
         GroupName = x.GroupName,
         Checked = false,
         NumberOfUsers = x.Users.Count
     });
 }
示例#4
0
 public User Create(UserModel korisnik, AppContext context)
 {
     return(new User()
     {
         Id = korisnik.Id,
         Admin = korisnik.Admin,
         FirstName = korisnik.FirstName,
         LastName = korisnik.LastName,
         Email = korisnik.Email,
         Occupation = korisnik.Occupation,
         DateOfBirth = Convert.ToDateTime(korisnik.DateOfBirth)
     });
 }
        public GroupWithUsers CreateGroupWithUsersModel(int id, AppContext context)
        {
            var userGroup = new Repository <UserGroup>(context).Get().FirstOrDefault(ug => ug.Id == id);
            var allUsers  = new Repository <User>(context).Get().ToList();

            var groupWithUsers = new GroupWithUsers
            {
                GroupId = id,
                Users   = allUsers.Select(u => Create(u, userGroup)).ToList()
            };

            return(groupWithUsers);
        }
        public AnalysisModel CreateAnalysisModel(Analysis analiza, AppContext context)
        {
            var version   = Create(context.Versions.SingleOrDefault(v => v.Id == analiza.Version.Id));
            var appEntity = context.Applications.SingleOrDefault(a => a.Versions.Any(v => v.Id == version.Id));
            var app       = CreateWithoutVersion(appEntity);

            return(new AnalysisModel()
            {
                Id = analiza.Id,
                Verzija = version,
                Aplikacija = app
            });
        }
示例#7
0
 public User Create(UserModel korisnik, AppContext context, string password)
 {
     return(new User()
     {
         Id = korisnik.Id,
         Admin = korisnik.Admin,
         FirstName = korisnik.FirstName,
         LastName = korisnik.LastName,
         Email = korisnik.Email,
         Password = ComputeSha256Hash(password),
         Occupation = korisnik.Occupation,
         DateOfBirth = Convert.ToDateTime(korisnik.DateOfBirth)
     });
 }
 public UserModel Create(User korisnik, AppContext context)
 {
     return(new UserModel()
     {
         Id = korisnik.Id,
         Admin = korisnik.Admin,
         FirstName = korisnik.FirstName,
         LastName = korisnik.LastName,
         Email = korisnik.Email,
         Name = korisnik.LastName + " " + korisnik.FirstName,
         Occupation = korisnik.Occupation,
         DateOfBirth = korisnik.DateOfBirth.ToShortDateString()
     });
 }
        public AnalysisModel CreateAnalysisModel(AnalysisApplicationForm analiza, AppContext context, User user)
        {
            var vers     = context.Versions.SingleOrDefault(v => v.AnalysisApplicationForm.Id == analiza.Id);
            var version  = Create(vers);
            var app      = Create(context.Applications.SingleOrDefault(a => a.Versions.Select(ver => ver.Id).Contains(vers.Id)));
            var analysis = context.Analyses.FirstOrDefault(a => a.Reviewer.Id == user.Id && a.Version.Id == version.Id);

            return(new AnalysisModel()
            {
                Id = (analysis != null) ? analysis.Id : 0,
                Verzija = version,
                Aplikacija = app,
                Created = analysis != null,
                AnalysisFormId = vers.AnalysisApplicationForm.Id,
                Korisnik = Create(user),
                Analyzed = (analysis != null) ? analysis.Analyzed : false
            });
        }
示例#10
0
        public Analysis CreateAnalysis(FillOutAnalysisModel model, AppContext context)
        {
            var analysisRepo = new Repository <Analysis>(context);
            var answersRepo  = new Repository <Answer>(context);
            var analysis     = new Analysis()
            {
                Reviewer            = context.Users.FirstOrDefault(u => u.Id == model.UserId),
                Version             = context.Versions.FirstOrDefault(v => v.AnalysisApplicationForm.Id == model.AnalysisId),
                QuestionsAndAnswers = new List <AnsweredQuestion>()
            };
            var heuristics    = context.AnalysisApplicationForms.Find(model.AnalysisId).Heuristics;
            var defaultAnswer = new Answer()
            {
                Description    = "",
                Location       = "",
                Level          = 0,
                Recommendation = "",
                Answered       = false
            };

            analysisRepo.Insert(analysis);

            foreach (var heuristic in heuristics)
            {
                var qa = new AnsweredQuestion()
                {
                    HeuristicText       = heuristic.HeuristicText,
                    HeuristicTitle      = heuristic.HeuristicTitle,
                    DatabaseHeuristicId = heuristic.Id
                };
                analysis.QuestionsAndAnswers.Add(qa);
            }

            analysisRepo.Update(analysis, analysis.Id);

            foreach (var question in analysis.QuestionsAndAnswers)
            {
                defaultAnswer.QuestionAnswerId = question.Id;
                defaultAnswer.HeuristicId      = question.DatabaseHeuristicId;
                answersRepo.Insert(defaultAnswer);
            }
            analysisRepo.Update(analysis, analysis.Id);
            return(analysis);
        }