This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<string> Upload(IFormFile files) | |
{ | |
string systemFileName = GenerateFileName(files.FileName); | |
string blobstorageconnection = _configuration.GetValue<string>("BlobConnectionString"); | |
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(blobstorageconnection); | |
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient(); | |
CloudBlobContainer container = blobClient.GetContainerReference(_configuration.GetValue<string>("BlobContainerName")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int GenerateOtp() | |
{ | |
Random random = new Random(); | |
int otp = random.Next(100000, 999999); | |
return otp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task ForgotPassword(ForgotPasswordRequest Request) | |
{ | |
var User = await _context.Authentication.SingleOrDefaultAsync( | |
x => x.Email == Request.Email && x.IsVerified); | |
if (User == null) throw new KeyNotFoundException("User Not Found"); | |
User.OTP = GenerateOtp(); | |
User.OTPExpiresAt = DateTime.Now.AddMinutes(5); | |
string Template = mailTemplate.GetPasswordResetTemplate(User.OTP, 5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GenerateToken(Authentication user) | |
{ | |
// generate token that is valid for 7 days | |
List<Claim> claims = new List<Claim> | |
{ | |
new Claim("email", user.Email), | |
new Claim("role", user.UserRole.ToString()), | |
new Claim("name", user.UserName), | |
new Claim("id", user.AuthId.ToString()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Final.MailServices | |
{ | |
public class MailService : IMailService | |
{ | |
private readonly IConfiguration _configuration; | |
public MailService(IConfiguration configuration) | |
{ | |
_configuration = configuration; | |
} | |
public async Task Send(string ToAddress, string subject, string body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Repository.Controllers | |
{ | |
[Route("api/User")] | |
public class UserController : Controller | |
{ | |
private IUserRepository _userRepository; | |
public userController() | |
{ | |
_userRepository = new UserRepository(new UserDBContext()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data.Entity; | |
using System.Linq; | |
namespace Repository.User | |
{ | |
public class UserRepository : IUserRepository | |
{ | |
private readonly UserDBContext _context; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Repository.User | |
{ | |
public interface IUserRepository | |
{ | |
IEnumerable<User> GetAll(); | |
User GetById(int UserID); | |
void Insert(User user); | |
void Update(User user); | |
void Delete(int UserID); | |
} |