This question already has an answer here:
- Non-static method requires a target 5 answers
I am getting error I am getting error "Non-static method requires a target." when i execute this code . I am a beginer at Api. It will be a great help.
public object StudentReg(tblreg reg)
{
try
{
var q = db.tblregs.FirstOrDefault(x => x.Email == reg.Email && x.Contact == reg.Contact);
if (q == null)
{
reg.Name = reg.Name;
reg.Email = reg.Email;
reg.Contact = reg.Contact;
reg.Passwod = reg.Passwod;
reg.IsApproved = reg.IsApproved;
reg.Crdt = DateTime.Now;
reg.Updt = null;
reg.Stat = true;
db.tblregs.Add(reg);
db.SaveChanges();
return new { result = "Employee Registration Successful" };
}
else
{
return new { result = "This Employee already exists" };
}
}
catch (Exception ex)
{
return new { error = ex.Message };
}
}
Aucun commentaire:
Enregistrer un commentaire