public void SubmitForm(ProfileSanitationCarEntity entity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);

                service.Update(entity);
            }
            else
            {
                entity.Create();

                service.Insert(entity);
            }
        }
Exemple #2
0
        /// <summary>
        /// 提交,修改
        /// </summary>
        /// <param name="tandasEntity"></param>
        /// <param name="keyValue"></param>
        public void SubmitForm(ProfileSanitationCarEntity entity, string keyValue, ProfileCarWorkItemContracts[] works)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);
            }
            else
            {
                entity.Create();
            }

            service.SubmitForm(entity, keyValue, works);

            try
            {
                LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "新建环卫车辆信息【" + entity.CarId + "】成功!");
            }
            catch
            {
            }
        }
        /// <summary>
        /// 单条
        /// 批量导入车辆信息
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="skipWhere"></param>
        /// <param name="coverWhere"></param>
        public void BatchCarSubmitFrom(ProfileSanitationCarEntity entity, Func <ProfileSanitationCarEntity, ProfileSanitationCarEntity, bool> skipWhere, Func <ProfileSanitationCarEntity, ProfileSanitationCarEntity, bool> coverWhere)
        {
            if (skipWhere != null)
            {
                Func <ProfileSanitationCarEntity, bool> dbSkipWhere = db => skipWhere(db, entity);

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

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

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

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

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

                    dbEntity.CarId     = entity.CarId;
                    dbEntity.CarType   = entity.CarType;
                    dbEntity.CompanyId = entity.CompanyId;
                    dbEntity.F_EnCode  = entity.F_EnCode;
                    dbEntity.WorkShift = entity.WorkShift;

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

                    return;
                }
            }

            entity.Create();
            this.service.Insert(entity);
        }