public override Task <SignReply> SendSign(SignRequest request, ServerCallContext context) { DateTime birthDate; birthDate = DateTime.ParseExact(request.Date.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture); string sign = ""; string[] dates = File.ReadAllLines(@"ZodiacSigns.txt"); for (int index = 0; index < dates.Length; index++) { string[] dateSplit = dates[index].Split(' '); var FirstDate = DateTime.ParseExact(dateSplit[1], "MM/dd", CultureInfo.InvariantCulture); var LastDate = DateTime.ParseExact(dateSplit[2], "MM/dd", CultureInfo.InvariantCulture); if ((birthDate.Month == FirstDate.Month && birthDate.Day >= FirstDate.Day) || (birthDate.Month == LastDate.Month && birthDate.Day <= LastDate.Day)) { sign = dateSplit[0]; break; } } return(Task.FromResult(new SignReply { Zodiac = sign })); }
public override Task <OperationResponse> SayHello(SignRequest request, ServerCallContext context) { var date = request.Sign; CultureInfo provider = CultureInfo.InvariantCulture; System.Console.Write("Date: "); System.Console.WriteLine(date); DateTime dt = DateTime.ParseExact(date, "dd/MM/yyyy", null); System.Collections.Generic.List <Zodie> lista = repo.GetAll(); foreach (Zodie zodie in lista) { zodie.ChangeYear(dt); //Console.WriteLine(zodie.Date1.ToString(),zodie.Date2.ToString()); } string sign = ""; foreach (Zodie zodie in lista) { if (dt.CompareTo(zodie.Date2) <= 0 && dt.CompareTo(zodie.Date1) >= 0) { sign = zodie.Sign; break; } } if (sign == "") { sign = "Capricorn"; } return(Task.FromResult(new OperationResponse() { Message = sign })); }