public string SaveSysEnum(SysEnumInfo sysEnumModel) { if (string.IsNullOrWhiteSpace(sysEnumModel.EnumName)) { return(MessageContent.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(sysEnumModel.EnumCode)) { return(MessageContent.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(sysEnumModel.EnumValue)) { return(MessageContent.Submit_Params_InvalidError); } Guid gId = Guid.Empty; Guid.TryParse(sysEnumModel.Id.ToString(), out gId); sysEnumModel.Id = gId; Guid parentId = Guid.Empty; Guid.TryParse(sysEnumModel.ParentId.ToString(), out parentId); sysEnumModel.ParentId = parentId; SysEnum bll = new SysEnum(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(sysEnumModel); } else { effect = bll.Insert(sysEnumModel); } if (effect == 110) { return(MessageContent.Submit_Exist); } if (effect > 0) { return("1"); } else { return(MessageContent.Submit_Error); } }
public string SaveSysEnum(SysEnumInfo model) { if (string.IsNullOrWhiteSpace(model.EnumName)) { return(MC.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(model.EnumCode)) { return(MC.Submit_Params_InvalidError); } if (string.IsNullOrWhiteSpace(model.EnumValue)) { return(MC.Submit_Params_InvalidError); } Guid gId = Guid.Empty; Guid.TryParse(model.Id.ToString(), out gId); model.Id = gId; Guid parentId = Guid.Empty; Guid.TryParse(model.ParentId.ToString(), out parentId); model.ParentId = parentId; SysEnum bll = new SysEnum(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); } else { using (TransactionScope scope = new TransactionScope()) { using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.Suppress)) { if (bll.IsExist(model.EnumCode, model.ParentId, model.Id)) { effect = 110; } else { effect = bll.Insert(model); } scope2.Complete(); } scope.Complete(); } } if (effect == 110) { return(MC.Submit_Exist); } if (effect > 0) { return("1"); } else { return(MC.Submit_Error); } }