Exemple #1
0
        /// <summary>
        /// 提交,修改
        /// </summary>
        /// <param name="tandasEntity"></param>
        /// <param name="keyValue"></param>
        public void SubmitForm(ProfileSanitationGarbageBoxEntity GarBoxEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                GarBoxEntity.Modify(keyValue);

                service.Update(GarBoxEntity);

                try
                {
                    //添加日志
                    LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "修改环卫垃圾箱房信息【" + GarBoxEntity.Address + "】成功!");
                }
                catch { }
            }
            else
            {
                GarBoxEntity.Create();

                service.Insert(GarBoxEntity);

                try
                {
                    //添加日志
                    LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "新建环卫垃圾箱房信息【" + GarBoxEntity.Address + "】成功!");
                }
                catch { }
            }
        }
Exemple #2
0
        /// <summary>
        /// 单条
        /// 批量导入
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="skipWhere"></param>
        /// <param name="coverWhere"></param>
        public void BatchSubmitFrom(ProfileSanitationGarbageBoxEntity entity, Func <ProfileSanitationGarbageBoxEntity, ProfileSanitationGarbageBoxEntity, bool> skipWhere, Func <ProfileSanitationGarbageBoxEntity, ProfileSanitationGarbageBoxEntity, bool> coverWhere)
        {
            if (skipWhere != null)
            {
                Func <ProfileSanitationGarbageBoxEntity, bool> dbSkipWhere = db => skipWhere(db, entity);

                var dbSkipQuery = this.service.dbcontext.Set <ProfileSanitationGarbageBoxEntity>().Where(dbSkipWhere);

                if (dbSkipQuery.Count() > 0)
                {
                    return;
                }
            }

            if (coverWhere != null)
            {
                Func <ProfileSanitationGarbageBoxEntity, bool> dbCoverWhere = db => coverWhere(db, entity);

                var dbCoverQuery = this.service.dbcontext.Set <ProfileSanitationGarbageBoxEntity>().Where(dbCoverWhere);

                if (dbCoverQuery.Count() > 0)
                {
                    var dbEntity = dbCoverQuery.FirstOrDefault();

                    dbEntity.CityId    = entity.CityId;
                    dbEntity.CountyId  = entity.CountyId;
                    dbEntity.ProjectId = entity.ProjectId;
                    dbEntity.F_EnCode  = entity.F_EnCode;
                    dbEntity.StreetId  = entity.StreetId;
                    dbEntity.Address   = entity.Address;

                    dbEntity.Modify(dbEntity.F_Id);
                    this.service.Update(dbEntity);

                    return;
                }
            }

            entity.Create();

            this.service.Insert(entity);
        }