public AdminBaseController() { glbAdmin = JsonHelper.JsonToT <SYS_Admin>(HttpContextCore.GetSession(ComConst.AdminLogin)); if (glbAdmin != null) { HttpContextCore.SetSession(ComConst.AdminLogin, JsonHelper.ToJson(glbAdmin)); } mjResult = new ModelJsonRet() { code = 0, errMsg = string.Empty, content = string.Empty }; }
public string AddNewAdmin(string username, string password, string personName, string phone) { var res = "账号重复,无法添加!"; var oldAdmin = UnitOfWork.Repository <SYS_Admin>().GetEntitiesAsync(x => x.Username == username).Result.FirstOrDefault(); if (oldAdmin == null) { var admin = new SYS_Admin { Username = username, Password = password, PersonName = personName, Phone = phone, CreateTime = DateTime.Now, Type = 2 }; UnitOfWork.Repository <SYS_Admin>().AddEntity(admin); if (UnitOfWork.CommitAsync().Result > 0) { res = "OK,添加成功"; } } return(res); }