public IEnumerable <Report> Report(DateTime fDate, DateTime sDate, string email) { var data = db.GetDataReport(fDate, sDate); var path = $"{env.WebRootPath}\\Reports\\{Guid.NewGuid()}.xlsx"; reportService.SaveData(data, path); mailService.SendMessage(email, path); return(data.Take(50)); }
public async Task <IActionResult> ForgetPassword([FromBody] ForgotPasswordDto forgotPasswordDto) { #region Validation if (!ModelState.IsValid) { return(BadRequest(new ApiMessage { Message = ModelState.Values.ToList()[0].Errors[0].ErrorMessage })); } var user = await _unitOfWork.UserService.GetByEmail(forgotPasswordDto.Email); if (user is null) { return(Ok(new ApiMessage { Message = ResponseMessage.ForgotPasswordNotAccepted })); } #endregion Validation user.Data.ConfirmCode = new Random(999999).ToString(); _unitOfWork.UserService.Edit(user.Data); await _unitOfWork.SaveChangesAsync(); await _emailServices.SendMessage(forgotPasswordDto.Email, ResponseMessage.ForgotPassword, $"{_hostAddress.ForgotPassword}{user.Data.ConfirmCode}"); await _smsService.SendMessage(user.Data.Mobile, ResponseMessage.ChangePasswordCodeIs + user.Data.ConfirmCode); return(Ok(new ApiMessage { Message = ResponseMessage.ForgotPasswordAccepted })); }