Ejemplo n.º 1
0
 public AnswerResponse Handle(ParticipatingInfo participant, AnswerRequest request)
 {
     if (participant.Answers.ContainsKey(participant.LastQuestion))
     {
         participant.Answers[participant.LastQuestion] = request.Message;
     }
     else
     {
         participant.Answers.Add(participant.LastQuestion, request.Message);
     }
     if (string.IsNullOrWhiteSpace(request.Message))
     {
         return(new AnswerResponse("گرایش نمی تواند خالی باشد", true));
     }
     if (request.Message.Contains(@"\") || request.Message.Contains(@"/") || request.Message.Contains(@"*") || request.Message.Contains(@"#") || request.Message.Contains(@"@"))
     {
         return(new AnswerResponse(@"'گرایش نمی تواند دارای کاراکتر های /\*#@ باشد", true));
     }
     if (Configure.MajorTypeString.All(it => it.Value.Trim() != request.Message.Trim()))
     {
         return(new AnswerResponse(@"'گرایش مورد نظر یافت نشد", true));
     }
     participant.Major = (MajorType)Configure.MajorTypeString.First(it => it.Value.Trim() == request.Message.Trim()).Key;
     return(new AnswerResponse());
 }
Ejemplo n.º 2
0
 public AnswerResponse Handle(ParticipatingInfo participant, AnswerRequest request)
 {
     if (participant.Answers.ContainsKey(participant.LastQuestion))
     {
         participant.Answers[participant.LastQuestion] = request.Message;
     }
     else
     {
         participant.Answers.Add(participant.LastQuestion, request.Message);
     }
     if (!Regex.IsMatch(request.Message, @"(0|\+98)?([ ]|,|-|[()]){0,2}9[1|2|3|4]([ ]|,|-|[()]){0,2}(?:[0-9]([ ]|,|-|[()]){0,2}){8}"))
     {
         return(new AnswerResponse("الگوی شماره تماس صحیح نمی باشد", true));
     }
     participant.PhoneNumber = request.Message;
     return(new AnswerResponse());
 }