Exemple #1
0
        public override OperationResult Create(FacilityInfo info)
        {
            OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
            using (var DbContext = new UCDbContext())
            {
                Facility entity = new Facility();
                DESwap.FacilityDTE(info, entity);
                FacilityRpt.Insert(DbContext, entity);

                /*关联功能是否为空*/
                if (info.FacilityFunctionInfoList != null)
                {
                    /*****新增列表*********/
                    List<FacilityFunction> insertlist = new List<FacilityFunction>();
                    /*****删除列表*********/
                    List<FacilityFunction> deletelist = new List<FacilityFunction>();

                    /*原有列表*/
                    var existlist = (from i in DbContext.FacilityFunction
                                     where i.FacilityId.Equals(info.Id)
                                     select i).ToList();

                    /*************如果为选中且没有关联表id则为新增******************/
                    foreach (var ffinfo in info.FacilityFunctionInfoList)
                    {
                        if (string.IsNullOrEmpty(ffinfo.Id) && ffinfo.Selected)
                        {
                            /*************如果为选中且没有关联表id则为新增******************/
                            ffinfo.Id = System.Guid.NewGuid().ToString();
                            ffinfo.FacilityId = info.Id;
                            FacilityFunction facilityFunction = new FacilityFunction();
                            DESwap.FacilityFunctionDTE(ffinfo, facilityFunction);
                            insertlist.Add(facilityFunction);
                        }
                        else if (!string.IsNullOrEmpty(ffinfo.Id) && ffinfo.Selected == false)
                        {
                            /*************如果为未选中且有关联表id则为删除******************/
                            var facilityFunction = existlist.Where(x => x.Id.Equals(ffinfo.Id)).FirstOrDefault();
                            if (facilityFunction == null)
                            {
                                deletelist.Add(facilityFunction);
                            }
                        }
                    }

                    FacilityFunctionRpt.Insert(DbContext, insertlist);
                    FacilityFunctionRpt.Delete(DbContext, deletelist);
                }

                DbContext.SaveChanges();

                result.ResultType = OperationResultType.Success;
                result.Message = "操作成功!";
                return result;
            }
        }
Exemple #2
0
        public override OperationResult Create(StationInfo info)
        {
            OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
            using (var DbContext = new UCDbContext())
            {
                Station entity = new Station();
                DESwap.StationDTE(info, entity);
                StationRpt.Insert(DbContext, entity);

                /*关联角色是否为空*/
                if (info.StationRoleInfoList != null)
                {
                    /*****新增列表*********/
                    List<StationRole> insertlist = new List<StationRole>();
                    /*****删除列表*********/
                    List<StationRole> deletelist = new List<StationRole>();

                    /*原有列表*/
                    var existlist = (from i in DbContext.StationRole
                                     where i.StationId.Equals(info.Id)
                                     select i).ToList();

                    /*************如果为选中且没有关联表id则为新增******************/
                    foreach (var rfinfo in info.StationRoleInfoList)
                    {
                        if (string.IsNullOrEmpty(rfinfo.Id) && rfinfo.Selected)
                        {
                            /*************如果为选中且没有关联表id则为新增******************/
                            rfinfo.Id = System.Guid.NewGuid().ToString();
                            rfinfo.StationId = info.Id;
                            StationRole StationRole = new StationRole();
                            DESwap.StationRoleDTE(rfinfo, StationRole);
                            insertlist.Add(StationRole);
                        }
                        else if (!string.IsNullOrEmpty(rfinfo.Id) && rfinfo.Selected == false)
                        {
                            /*************如果为未选中且有关联表id则为删除******************/
                            var StationRole = existlist.Where(x => x.Id.Equals(rfinfo.Id)).FirstOrDefault();
                            if (StationRole == null)
                            {
                                deletelist.Add(StationRole);
                            }
                        }
                    }

                    StationRoleRpt.Insert(DbContext, insertlist);
                    StationRoleRpt.Delete(DbContext, deletelist);
                }
                DbContext.SaveChanges();

                result.ResultType = OperationResultType.Success;
                result.Message = "操作成功!";
                return result;
            }
        }
 public virtual OperationResult Create(StationInfo info)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     using (var DbContext = new UCDbContext())
     {
       Station entity = new Station();
       DESwap.StationDTE(info, entity);
       StationRpt.Insert(DbContext, entity);
       DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Create(CompanyClientTypeInfo info)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     using (var DbContext = new UCDbContext())
     {
       CompanyClientType entity = new CompanyClientType();
       DESwap.CompanyClientTypeDTE(info, entity);
       CompanyClientTypeRpt.Insert(DbContext, entity);
       DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Create(IEnumerable<StationInfo> infoList)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     List<Station> eList = new List<Station>();
     infoList.ForEach(x =>
     {
         Station entity = new Station();
         DESwap. StationDTE(x, entity);
         eList.Add(entity);
     });
     using (var DbContext = new UCDbContext())
     {
     StationRpt.Insert(DbContext, eList);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Remove(IEnumerable<string> keyList)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     List<Station> eList = new List<Station>();
     using (var DbContext = new UCDbContext())
     {
     keyList.ForEach(x =>
     {
         Station entity = StationRpt.Get(DbContext, x);
         eList.Add(entity);
     });
     StationRpt.Delete(DbContext, eList);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Remove(string key)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     using (var DbContext = new UCDbContext())
     {
     Station entity = StationRpt.Get(DbContext, key);
     StationRpt.Delete(DbContext, entity);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Modify(IEnumerable<CompanyClientTypeInfo> infoList)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     List<CompanyClientType> eList = new List<CompanyClientType>();
     infoList.ForEach(x =>
     {
         CompanyClientType entity = new CompanyClientType();
         DESwap. CompanyClientTypeDTE(x, entity);
         eList.Add(entity);
     });
     using (var DbContext = new UCDbContext())
     {
     CompanyClientTypeRpt.Update(DbContext, eList);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Modify(IEnumerable<RoleFacilityInfo> infoList)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     List<RoleFacility> eList = new List<RoleFacility>();
     infoList.ForEach(x =>
     {
         RoleFacility entity = new RoleFacility();
         DESwap. RoleFacilityDTE(x, entity);
         eList.Add(entity);
     });
     using (var DbContext = new UCDbContext())
     {
     RoleFacilityRpt.Update(DbContext, eList);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Modify(RoleFacilityInfo info)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     using (var DbContext = new UCDbContext())
     {
     RoleFacility entity = RoleFacilityRpt.Get(DbContext, info.Id);
     DESwap.RoleFacilityDTE(info, entity);
     RoleFacilityRpt.Update(DbContext, entity);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
 public virtual OperationResult Modify(CompanyStaffInfo info)
 {
     OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
     using (var DbContext = new UCDbContext())
     {
     CompanyStaff entity = CompanyStaffRpt.Get(DbContext, info.Id);
     DESwap.CompanyStaffDTE(info, entity);
     CompanyStaffRpt.Update(DbContext, entity);
     DbContext.SaveChanges();
     }
     result.ResultType = OperationResultType.Success;
     result.Message = "操作成功!";
     return result;
 }
Exemple #12
0
        /// <summary>
        /// 重载修改权限信息内容,编辑关承功能列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public override OperationResult Modify(RoleInfo info)
        {
            OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!");
            using (var DbContext = new UCDbContext())
            {
                Role entity = RoleRpt.Get(DbContext, info.Id);
                DESwap.RoleDTE(info, entity);
                RoleRpt.Update(DbContext, entity);

                /*关联权限是否为空*/
                if (info.RoleFacilityInfoList != null)
                {
                    /*****新增列表*********/
                    List<RoleFacility> insertlist = new List<RoleFacility>();
                    /*****删除列表*********/
                    List<RoleFacility> deletelist = new List<RoleFacility>();

                    /*原有列表*/
                    var existlist = (from i in DbContext.RoleFacility
                                     where i.RoleId.Equals(info.Id)
                                     select i).ToList();

                    /*************如果为选中且没有关联表id则为新增******************/
                    foreach (var rfinfo in info.RoleFacilityInfoList)
                    {
                        if (string.IsNullOrEmpty(rfinfo.Id) && rfinfo.Selected)
                        {
                            /*************如果为选中且没有关联表id则为新增******************/
                            rfinfo.Id = System.Guid.NewGuid().ToString();
                            rfinfo.RoleId = info.Id;
                            RoleFacility roleFacility = new RoleFacility();
                            DESwap.RoleFacilityDTE(rfinfo, roleFacility);
                            insertlist.Add(roleFacility);
                        }
                        else if (!string.IsNullOrEmpty(rfinfo.Id) && rfinfo.Selected == false)
                        {
                            /*************如果为未选中且有关联表id则为删除******************/
                            var facilityFunction = existlist.Where(x => x.Id.Equals(rfinfo.Id)).FirstOrDefault();
                            if (facilityFunction != null)
                            {
                                deletelist.Add(facilityFunction);
                            }
                        }
                    }

                    RoleFacilityRpt.Insert(DbContext, insertlist);
                    RoleFacilityRpt.Delete(DbContext, deletelist);
                }

                DbContext.SaveChanges();

                result.ResultType = OperationResultType.Success;
                result.Message = "操作成功!";
                return result;
            }
        }