public BeginSurveyViewModel RegisterSurvey(RegisterSurveyViewModel model) { Person person = AddNewPersonFrom(model); ICollection <Answer> answers = _answerService.GenerateAnswers(); Survey survey = GenerateNewSurvey(person); survey.Answer = answers; _context.Survey.Add(survey); _context.SaveChanges(); BeginSurveyViewModel beginSurvey = GenerateBeginSurveyModel(answers); beginSurvey.SurveyCommand = _context.Question.AsNoTracking().First().Questiondescription; return(beginSurvey); }
public void ParsePhotos(string folder) { IEnumerable <Photo> currentPhotos = _entitySearchAlgorithm.ListEntities(folder); IEnumerable <string> existingPhotoHashes = _context.Photo.Select(photo => photo.Photohash).ToList(); IEnumerable <string> currentPhotoHashes = currentPhotos.Select(e => e.Photohash); AddNewPhotos(currentPhotoHashes, existingPhotoHashes, currentPhotos); DeleteNonUsedPhotos(existingPhotoHashes, currentPhotoHashes); _context.SaveChanges(); }