This my Login Method in Repository Class Where i'm writing a logic to check the email id and password that will matches already registered user in the database and returns true if the email and password matched in db
public bool Login(Models.Login user)
{
Eseal.UserRegister u = null;
try
{
string Dpassword = Decrypt(user.Password);
using (var dbContext = new MVCDEMOEntities())
{
u = dbContext.UserRegisters.Where(query => query.EmailID.Equals(user.EmailID) && query.Password.Equals(user.Password)).SingleOrDefault();
}
if (u == null)
return false
else
return true;
}
catch (Exception)
{
throw;
}
}
This my Account Controller code
public ActionResult Login(Models.Login user)
{
try
{
var services = new RegisterService();
services.LoginRegister(user);
return RedirectToAction("Privacy");
}
catch (Exception)
{
throw;
}
}
This is my save register method
public string SaveRegister(Models.UserRegister model)
{
try
{
using (var dbcontext = new MVCDEMOEntities())
{
var dbRegister = new Eseal.UserRegister()
{
Id = Guid.NewGuid(),
Password = encrypt(model.Password),
EmailID = model.EmailID,
ContactNumber = model.ContactNumber,
CreatedOn = DateTime.Now,
CreatedBy = 1,
UpdatedOn=null,
UpdatedBy=null,
IsExists= true
};
dbcontext.UserRegisters.Add(dbRegister);
dbcontext.SaveChanges();
}
}
This is my Service Class
public void LoginRegister(Models.Login user)
{
var result = _repository.Login(user);
}