我遇到错误“非静态方法需要目标”。当我执行此代码。我是Api的初学者。这将是一个很大的帮助。
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 };
}
}