public IActionResult Edit(forestViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                var entity = _dbContext.Woods.FirstOrDefault(x => x.WoodsUuid == model.WoodsUuid);
                if (entity == null)
                {
                    response.SetFailed("不存在");
                    return(Ok(response));
                }
                if (_dbContext.Woods.Count(x => x.ShebeiId == model.ShebeiId && x.WoodsUuid != model.WoodsUuid) > 0)
                {
                    response.SetFailed("设备ID已存在");
                    return(Ok(response));
                }
                entity.ForestName = model.ForestName;
                //entity.ForestAddress = model.ForestAddress;
                entity.ShebeiId      = model.ShebeiId;
                entity.ShebeiType    = model.ShebeiType;
                entity.ShebeiAddress = model.ShebeiAddress;
                entity.ManagePhone   = model.ManagePhone;
                if (model.MapRegion != "" && model.MapRegion != null)
                {
                    model.MapRegion = model.MapRegion.Replace("0,0-", "");
                }
                if (model.MapRegion != "0,0")
                {
                    entity.MapRegion = model.MapRegion;
                }
                if (model.MapRegion == null || model.MapRegion == "" || model.MapRegion == "0,0")
                {
                    entity.MapRegion = null;
                }
                entity.Lon          = model.Lon;
                entity.Lat          = model.Lat;
                entity.Guanliren    = model.Guanliren;
                entity.ShebeiStaues = model.ShebeiStaues;
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("编辑", "成功:编辑:森林防火设备信息一条数据", _dbContext);
                }
                response = ResponseModelFactory.CreateInstance;
                return(Ok(response));
            }
        }
        public IActionResult Create(forestViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                if (_dbContext.Woods.Count(x => x.ShebeiId == model.ShebeiId) > 0)
                {
                    response.SetFailed("设备ID已存在");
                    return(Ok(response));
                }
                var entity = _mapper.Map <forestViewModel, Woods>(model);
                model.MapRegion = model.MapRegion.Replace("0,0-", "");
                if (model.MapRegion != "0,0")
                {
                    entity.MapRegion = model.MapRegion;
                }
                if (model.MapRegion == "0,0" || model.MapRegion.Trim() == "")
                {
                    entity.MapRegion = null;
                }
                entity.WoodsUuid   = Guid.NewGuid();
                entity.IsDeleted   = 0;
                entity.ManagePhone = model.ManagePhone;
                entity.AddTime     = DateTime.Now.ToString("yyyy-MM-dd");
                entity.AddPeople   = AuthContextService.CurrentUser.DisplayName;
                _dbContext.Woods.Add(entity);
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("添加", "成功:添加:森林防火设备信息一条数据", _dbContext);
                }
                response.SetSuccess();
                return(Ok(response));
            }
        }