public void CreateRole(VM.RoleItemModel role) { MessageModel message = null; if (role == null) { message = new MessageModel() { IsSuccess = false, Message = MessageResource.Role_Empty_ErrorMessage + "," + MessageResource.Message_CommonUpdateFail, MessageType = MessageType.InsertFailure }; return; } if (ctx.Common_Authen_Role.Any(i => i.RoleName == role.RoleName)) { message = new MessageModel() { IsSuccess = false, MessageType = MessageType.InsertFailure, Message = MessageResource.Role_Exits_ErrorMessage + "," + MessageResource.Message_CommonUpdateFail }; return; } var maxId = ctx.Common_Authen_Role.Max(b => b.RoleID) + 1; var mdRole = this.ConvertDataModel(role); mdRole.ShowFlag = true; mdRole.RoleID = maxId; ctx.Common_Authen_Role.Add(mdRole); ctx.SaveChanges(); message = new MessageModel() { IsSuccess = true, MessageType = MessageType.InsertSuccess, Message = MessageResource.Message_CommonInsertSuccessful }; Message = message; }
public bool CreateUser(VM.VmTblUser model) { if (model == null) { //Message = MessageModel.InsertFailue(MessageResource.FaultCode_Empty_ErrorMessage + "," + MessageResource.Message_CommonInsertFail); Message = MessageModel.InsertFailue("页面对象为空!"); return(false); } var mdUser = this.ConvertToDataModel(model, null); context.Common_Authen_User.Add(mdUser); context.SaveChanges(); Message = MessageModel.InsertSuccess(); return(true); }
public bool CreateSampleItem(VM.SampleItemModel model) { if (model == null) { //Message = MessageModel.InsertFailue(MessageResource.QualificaitonPage_Empty_ErrorMessage + "," + MessageResource.Message_CommonInsertFail); Message = MessageModel.InsertFailue(MessageResource.Message_CommonInsertFail); return(false); } var item = this.ConvertToDataModel(model); context.tbl_Sample.Add(item); context.SaveChanges(); Message = MessageModel.InsertSuccess(); return(true); }