public string Allocate(JObject json) { try { int AR_AccountId = Convert.ToInt32(json["ACC_ID"].ToString()); using (NERPEntities context = new NERPEntities()) { //删除已有的数据集合 List <SYS_AccountRole> tempList = context.SYS_AccountRole.Where(c => c.AR_AccountId == AR_AccountId).ToList(); context.SYS_AccountRole.RemoveRange(tempList); context.SaveChanges(); //循环添加 for (int i = 0; i < json["RoleValueArray"].Count(); i++) { string tempRoleName = json["RoleValueArray"][i].ToString(); SYS_AccountRole _role = new SYS_AccountRole(); _role.AR_AccountId = AR_AccountId; int AR_SystemRoleId = context.SYS_SystemRole.Where(c => c.ROLE_Name == tempRoleName).FirstOrDefault().ROLE_Id; _role.AR_SystemRoleId = AR_SystemRoleId; DPBase.Add(_role); } return("保存成功!"); } } catch (Exception ex) { throw new Exception(ex.Message + "转换的过程中发生了错误!"); } }
public int Add(JObject json) { SYS_SystemRole model = JsonToObject <SYS_SystemRole>(json); model.ROLE_CreatedBy = UserSession.userid; //当前用户 model.ROLE_CreatedOn = DateTime.Now; return(DPBase.Add(model)); }
public int Add(JObject json) { SYS_Account model = JsonToObject <SYS_Account>(json); model.ACC_CreatedBy = UserSession.userid; //当前用户 model.ACC_CreatedOn = DateTime.Now; return(DPBase.Add(model)); }
public int Add(JObject json) { SYS_Button model = JsonToObject <SYS_Button>(json); model.BTN_IsSuspended = false; //默认为false model.BTN_Mark = model.BTN_Name_En; model.BTN_CreatedBy = UserSession.username; //当前用户 model.BTN_CreatedOn = DateTime.Now; return(DPBase.Add(model)); }
public string AddNewButtonGroup(JObject json) { json["BG_OrderIndex"] = 0; SYS_ButtonGroup bGroup = (SYS_ButtonGroup)(JsonConvert.DeserializeObject(json.ToString(), typeof(SYS_ButtonGroup))); bGroup.BG_CreatedOn = DateTime.Now; bGroup.BG_IsSuspended = false; DPBase.Add(bGroup); return("保存成功!"); }
string IExcuteModel <T> .AddModel(T t) { DPBase.Add(t); return("新增成功!"); }