public async Task <IActionResult> SendVerificationEmail([FromBody] EmailCode emailCode) { if (Utils.IsEmailValid(emailCode.Email)) { string code = Utils.GenerateRandomCode(); if (await UserDB.IsMobileUserExists(_context, emailCode.Email)) { MobileUser us = await UserDB.GetMobileUserByEmail(_context, emailCode.Email); us.EmailCode = code; User user = await UserDB.GetUserByEmail(_context, emailCode.Email); if (user != null) { us.TelegramId = user.TelegramId; } _context.MobileUsers.Update(us); _context.SaveChanges(); } else { UserDB.AddMobileUser(_context, emailCode.Email, code); } await Utils.SendEmailAsync(emailCode.Email, "Потверждение почты", $"Ваш кода для потверждения почты: {code}"); return(Ok()); } return(BadRequest()); }