public ResponseInfoModel Delete([FromBody] DeleteWildlifeManagementInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                CheckModelState();

                int[] idInts = ConvertStringToIntArr(input.IDs);

                if (_wildlifeContentService.GetNoTrackingList(a => idInts.Contains(a.WildlifeID)).Any())
                {
                    throw new UserFriendlyException("有详情信息的不能删除");
                }

                if (!_wildlifeManagerService.Delete(a => idInts.Contains(a.ID)))
                {
                    json.Success = 0;
                    json.Result  = LocalizationConst.DeleteFail;
                }
                else
                {
                    foreach (var id in idInts)
                    {
                        _logService.Insert(new Log()
                        {
                            ActionContent = LocalizationConst.Delete,
                            SourceType    = _moduleName,
                            SourceID      = id,
                            LogUserID     = input.UserID,
                            LogTime       = DateTime.Now,
                            LogIPAddress  = IPHelper.GetIPAddress,
                        });
                    }
                }
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/wildlifemanager/delete", LocalizationConst.DeleteFail);
            }
            return(json);
        }
Exemple #2
0
        public ResponseInfoModel DeleteRoutespot([FromBody] DeleteWildlifeManagementInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                int[] idInts = ConvertStringToIntArr(input.IDs);

                if (!_routeViewSpotService.Delete(a => idInts.Contains(a.ID)))
                {
                    json.Success = 0;
                    json.Result  = LocalizationConst.DeleteFail;
                }
                else
                {
                    foreach (var id in idInts)
                    {
                        _logService.Insert(new Log()
                        {
                            ActionContent = LocalizationConst.Delete,
                            SourceType    = _moduleName,
                            SourceID      = id,
                            LogUserID     = input.UserID,
                            LogTime       = DateTime.Now,
                            LogIPAddress  = IPHelper.GetIPAddress,
                        });
                    }
                }
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/route/deleteroutespot", LocalizationConst.DeleteFail);
            }
            return(json);
        }