public async Task<MatchingField[]> GetMatchingQuestionariesAsync(Questionary questionary) { var questionaries = await _repository.GetAll() .Where( q => q.Id != questionary.Id && ( q.IINPhysic == questionary.IINPhysic || q.Email == questionary.Email || q.MobilePhone == questionary.MobilePhone || q.PassportSeries == questionary.PassportSeries && q.PassportNumber == questionary.PassportNumber)) .ToArrayAsync(); var iinMatches = new MatchingField { FieldName = "iinPhysic", Questionaries = questionaries.Where(q => q.IINPhysic == questionary.IINPhysic) .Select(q => new QuestionaryDisplayDto(q)) .ToArray() }; var emailMatches = new MatchingField { FieldName = "email", Questionaries = questionaries.Where(q => q.Email == questionary.Email) .Select(q => new QuestionaryDisplayDto(q)).ToArray() }; var phoneMatches = new MatchingField { FieldName = "mobilePhone", Questionaries = questionaries.Where(q => q.MobilePhone == questionary.MobilePhone) .Select(q => new QuestionaryDisplayDto(q)).ToArray() }; var passportQuestionaries = questionaries.Where( q => q.PassportSeries == questionary.PassportSeries && q.PassportNumber == questionary.PassportNumber) .Select(q => new QuestionaryDisplayDto(q)).ToArray(); var passportSeriesMatches = new MatchingField { FieldName = "passportSeries", Questionaries = passportQuestionaries }; var passportNumberMatches = new MatchingField { FieldName = "passportNumber", Questionaries = passportQuestionaries }; return new[] {iinMatches, phoneMatches, emailMatches, passportSeriesMatches, passportNumberMatches}.Where( m => m.Questionaries.Any()).ToArray(); }
public async Task<IHttpActionResult> Post(Questionary questionary) { if (!ModelState.IsValid) { return BadRequest(ModelState); } using (var repository = new Repository<Questionary>()) { repository.Add(questionary); await repository.SaveChangesAsync(); return Ok(); } }
private static IList<Questionary> FromExcelSheet(ExcelWorksheet worksheet) { var list = new List<Questionary>(); for (int i = 2; i <= worksheet.Dimension.End.Row; i++) { var questionary = new Questionary { LastName = worksheet.GetValue<string>(i, 3), FirstName = worksheet.GetValue<string>(i, 4), Patronymic = worksheet.GetValue<string>(i, 5), BirthDate = worksheet.GetValue<DateTime>(i, 6), MobilePhone = worksheet.GetValue<string>(i, 7), Email = worksheet.GetValue<string>(i, 8), PassportSeries = worksheet.GetValue<string>(i, 9), PassportNumber = worksheet.GetValue<string>(i, 10), IINPhysic = worksheet.GetValue<string>(i, 11), PassportIssued = worksheet.GetValue<string>(i, 12), AddressLocation = worksheet.GetValue<string>(i, 13) }; list.Add(questionary); } return list; }
public QuestionaryExcelFileActionResult(Questionary[] data, string fileName) { _data = data; _filename = fileName; }
public QuestionaryDisplayDto(Questionary q) { Id = q.Id; DisplayName = $"{q.LastName} {q.FirstName} {q.Patronymic} (ID: {q.Id}, INN: {q.IINPhysic})"; }