public override OPResult Delete(OrganizationGoodReturnRate entity) { if (entity.ID == default(int)) { return new OPResult { IsSucceed = true, Message = "删除成功!" } } ; var bo = (OrganizationGoodReturnRateBO)entity; using (TransactionScope scope = new TransactionScope()) { try { LinqOP.Delete <OrganizationGoodReturnRatePerQuarter>(o => o.RateID == entity.ID); LinqOP.Delete <OrganizationGoodReturnRate>(entity); scope.Complete(); return(new OPResult { IsSucceed = true, Message = "删除成功!" }); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message }); } } }
/// <summary> /// 删除角色,同时删除角色权限和用户角色映射关系 /// </summary> /// <param name="rid">角色ID</param> /// <returns>删除是否成功</returns> public override OPResult Delete(SysRole entity) { int rid = entity.ID; using (TransactionScope scope = new TransactionScope()) { try { LinqOP.Delete <SysRoleModule>(rm => rm.RoleId == rid); VMGlobal.SysProcessQuery.DB.ExecuteNonQuery("CleanUpDirtyProcess", rid); LinqOP.Delete <SysRole>(r => r.ID == rid); LinqOP.Delete <SysUserRole>(ur => ur.RoleId == rid); scope.Complete(); return(new OPResult { IsSucceed = true, Message = "删除成功!" }); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message }); } } }
public OPResult Delete(OrganizationGoodReturnRatePerQuarter entity) { if (entity.ID == default(int)) { return new OPResult { IsSucceed = true, Message = "删除成功!" } } ; try { LinqOP.Delete <OrganizationGoodReturnRatePerQuarter>(entity); return(new OPResult { IsSucceed = true, Message = "删除成功!" }); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message }); } } }
private OPResult Update(SysUserBO user) { var roleIDs = RolesCurrentUserCover.Select(rs => rs.ID);//加上ToList()在下面执行时就抛出Contains不支持的异常,坑爹 List <SysUserRole> urs = new List <SysUserRole>(); foreach (var rs in user.Roles) { SysUserRole ur = new SysUserRole { UserId = user.ID, RoleId = rs.ID, CreatorID = VMGlobal.CurrentUser.ID }; urs.Add(ur); } var brandIDs = VMGlobal.PoweredBrands.Select(bs => bs.ID); List <UserBrand> ubs = new List <UserBrand>(); foreach (var bs in user.Brands) { UserBrand ub = new UserBrand { UserID = user.ID, BrandID = bs.ID, CreatorID = VMGlobal.CurrentUser.ID }; ubs.Add(ub); } using (TransactionScope scope = new TransactionScope()) { try { LinqOP.Update <SysUser>(user); LinqOP.Delete <SysUserRole>(ur => roleIDs.Contains(ur.RoleId) && ur.UserId == user.ID); VMGlobal.SysProcessQuery.LinqOP.Delete <UserBrand>(ub => brandIDs.Contains(ub.BrandID) && ub.UserID == user.ID); LinqOP.Add <SysUserRole>(urs); VMGlobal.SysProcessQuery.LinqOP.Add <UserBrand>(ubs); scope.Complete(); return(new OPResult { IsSucceed = true, Message = "更新成功." }); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message }); } } }
private OPResult Update(SysRoleBO role) { List <SysRoleModule> rms = new List <SysRoleModule>(); foreach (var m in role.Modules) { SysRoleModule rm = new SysRoleModule { RoleId = role.ID, ModuleId = m.ID }; rms.Add(rm); } //该角色被删除的菜单权限,拥有该角色的用户的所有下级用户的相应菜单权限也要一起删除,若同样权限是其它角色赋予则不删除 //var oldrms = _query.LinqOP.Search<SysRoleModule>(rm => rm.RoleId == role.ID).ToList(); //oldrms.Except(rms);//原列表中有新列表中没有的权限映射(待级联删除的) using (TransactionScope scope = new TransactionScope()) { try { LinqOP.Update <SysRole>(role); LinqOP.Delete <SysRoleModule>(rm => rm.RoleId == role.ID); LinqOP.Add <SysRoleModule>(rms); VMGlobal.SysProcessQuery.DB.ExecuteNonQuery("CleanUpDirtyProcess", role.ID); scope.Complete(); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message }); } } if (_rolesOfCurrentOrgnization != null) { var roleUpdate = _rolesOfCurrentOrgnization.FirstOrDefault(r => r.ID == role.ID); if (roleUpdate != null) { int index = _rolesOfCurrentOrgnization.IndexOf(roleUpdate); _rolesOfCurrentOrgnization[index] = role; //roleUpdate = role; } } return(new OPResult { IsSucceed = true, Message = "更新成功." }); }
public override OPResult AddOrUpdate(VIPCard entity) { VIPCardBO card = (VIPCardBO)entity; int id = card.ID; var action = new Action(() => { if (id != default(int)) { LinqOP.Delete <VIPCardKindMapping>(o => o.CardID == id); } var kindsmap = card.Kinds.Select(o => new VIPCardKindMapping { CardID = card.ID, KindID = o.ID }).ToList(); LinqOP.Add <VIPCardKindMapping>(kindsmap); }); using (TransactionScope scope = new TransactionScope()) { try { var result = base.AddOrUpdate(entity); if (!result.IsSucceed) { return(result); } else { action(); } scope.Complete(); return(new OPResult { IsSucceed = true, Message = "保存成功!" }); } catch (Exception e) { card.ID = default(int); return(new OPResult { IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message }); } } }
public OPResult SetStylesForTactic(int tacticID, IEnumerable <RetailTacticProStyleMapping> mapping) { using (TransactionScope scope = new TransactionScope()) { try { LinqOP.Delete <RetailTacticProStyleMapping>(o => o.TacticID == tacticID); LinqOP.Add <RetailTacticProStyleMapping>(mapping); scope.Complete(); return(new OPResult { IsSucceed = true }); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "设置失败,失败原因:\n" + e.Message }); } } }
public override OPResult Delete(VIPCard vip) { if (!DownHierarchyOrganizationIDArray.Contains(vip.OrganizationID)) { return(new OPResult { IsSucceed = false, Message = "只能删除本级或下级机构创建的VIP信息." }); } if (LinqOP.Any <BillRetail>(o => o.VIPID == vip.ID)) { return(new OPResult { IsSucceed = false, Message = "该VIP存在消费记录,不可删除." }); } using (TransactionScope scope = new TransactionScope()) { try { LinqOP.Delete <VIPCard>(c => c.ID == vip.ID); LinqOP.Delete <VIPCardKindMapping>(c => c.CardID == vip.ID); LinqOP.Delete <VIPPointTrack>(c => c.VIPID == vip.ID); LinqOP.Delete <VIPPredepositTrack>(c => c.VIPID == vip.ID); scope.Complete(); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = "删除失败,失败原因:\n" + e.Message }); } } return(new OPResult { IsSucceed = true, Message = "删除成功!" }); }