public void CheckDate(DateTime date) { var age = DateTime.Today.Date.Year - date.Date.Year; if (date > DateTime.Today.AddYears(-age)) { age--; } if (age < 0) { MessageBox.Show("Помилка. Ви ще не народилися."); } else if (age >= 135) { MessageBox.Show("Помилка. Ви вже повинні були померти."); } else { if (LModel.isBirthday(date.Date)) { MessageBox.Show("Вітаємо з днем народження!"); } Info info = new Info { Age = age, WesternZodiac = LModel.FindWestZodiac(date), ChineseZodiac = LModel.FindChineseZodiac(date.Year), IsBirthdayToday = LModel.isBirthday(date.Date) }; LModel._storage.ChangeInfo(info); } }
public IActionResult Login([FromBody] LModel user) { if (user == null) { return(BadRequest("Request invalid")); } if (user.UserName == "Loginprueba1" && user.Password == "Prueba098@") { var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("SuperSecretKey@123")); var signincredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256); var tokenoptions = new JwtSecurityToken( issuer: "http://localhots:5000", audience: "http://localhots:5000", claims: new List <Claim>(), expires: DateTime.Now.AddMinutes(5), signingCredentials: signincredentials ); var tokensString = new JwtSecurityTokenHandler().WriteToken(tokenoptions); return(Ok(new { Token = tokensString })); } else { return(Unauthorized()); } }