예제 #1
0
        /// <summary>
        /// To Delete a Farm
        /// </summary>
        /// <param name="farmId">Farm Id of the Farm to be deleted</param>
        /// <param name="lastModifyBy">Last Modified By User Id</param>
        public void DeleteFarm(int farmId, int lastModifyBy)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            //Check if there is a Plot/s attached to the farm.
            if (dao.GetPlotCountForFarm(farmId) == 0)
            {
                dao.DeleteFarm(farmId, lastModifyBy);
            }
            else
            {
                throw new Exception("Farm is not Empty");
            }
        }
예제 #2
0
 public JsonResult DeleteFarm(string farmIds)
 {
     CheckPermission();
     using (var result = new ResponseResult <object>())
     {
         if (farmIds != null)
         {
             var aryStringFarmId = farmIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             var aryIntFarmId    = new int[aryStringFarmId.Length];
             for (var i = 0; i < aryStringFarmId.Length; i++)
             {
                 aryIntFarmId[i] = int.Parse(aryStringFarmId[i]);
             }
             result.Entity = _farmService.DeleteFarm(aryIntFarmId);
         }
         else
         {
             result.IsSuccess         = false;
             result.State.Id          = (int)ResponseStatusCode.InvalidArgument;
             result.State.Description = ResponseStatusCode.InvalidArgument.GetDescription();
         }
         return(new JsonResultEx(result));
     }
 }