public Task <bool> DeleteAsync(CostCentersVM entity)
 {
     return(Task.Run <bool>(() =>
     {
         COST_CENTERS cur = new COST_CENTERS()
         {
             COST_CENTER_AR_NAME = entity.COST_CENTER_AR_NAME,
             COST_CENTER_CODE = entity.COST_CENTER_CODE,
             COST_CENTER_EN_NAME = entity.COST_CENTER_EN_NAME,
             COST_CENTER_ID = entity.COST_CENTER_ID,
             COST_CENTER_MASTER_ID = entity.COST_CENTER_MASTER_ID,
             COST_CENTER_REMARKS = entity.COST_CENTER_REMARKS,
             AddedBy = entity.AddedBy,
             AddedOn = entity.AddedOn,
             Disable = entity.Disable,
             UpdatedBy = entity.UpdatedBy,
             updatedOn = entity.updatedOn,
             OpeningExpenses = entity.OpeningExpenses,
             OpeningIncome = entity.OpeningIncome,
             ExpectedExpenses = entity.ExpectedExpenses,
             ExpectedIncome = entity.ExpectedIncome,
         };
         costCentersRepo.Delete(cur, entity.COST_CENTER_ID);
         return true;
     }));
 }
        public async Task <IHttpActionResult> update([FromBody] CostCentersVM entity)
        {
            var result = await costCentersService.UpdateAsync(entity);

            await LogData(entity.COST_CENTER_CODE, entity.COST_CENTER_ID.ToString());

            return(Ok(result));
        }
        public async Task <IHttpActionResult> add([FromBody] CostCentersVM entity)
        {
            var result = await costCentersService.InsertAsync(entity);

            await LogData(entity.COST_CENTER_CODE, result.ToString());

            if (result != 0)
            {
                return(Ok(true));
            }
            return(Ok(false));
        }
        public async Task <IHttpActionResult> delete([FromBody] CostCentersVM entity)
        {
            var q1 = entryDetailsService.getByCostCenter(entity.COST_CENTER_ID);
            var q  = billMasterService.getByCostCenter(entity.COST_CENTER_ID);

            if (q.Count == 0 && q1.Count == 0)
            {
                var result = await costCentersService.DeleteAsync(entity);
                await LogData(entity.COST_CENTER_CODE, entity.COST_CENTER_ID.ToString());

                return(Ok(result));
            }

            else
            {
                return(Ok(false));
            }
            //return Ok(await costCentersService.DeleteAsync(entity));
        }
        public bool Delete(CostCentersVM entity)
        {
            COST_CENTERS cur = new COST_CENTERS()
            {
                COST_CENTER_AR_NAME   = entity.COST_CENTER_AR_NAME,
                COST_CENTER_CODE      = entity.COST_CENTER_CODE,
                COST_CENTER_EN_NAME   = entity.COST_CENTER_EN_NAME,
                COST_CENTER_ID        = entity.COST_CENTER_ID,
                COST_CENTER_MASTER_ID = entity.COST_CENTER_MASTER_ID,
                COST_CENTER_REMARKS   = entity.COST_CENTER_REMARKS,
                AddedBy   = entity.AddedBy,
                AddedOn   = entity.AddedOn,
                Disable   = entity.Disable,
                UpdatedBy = entity.UpdatedBy,
                updatedOn = entity.updatedOn
            };

            costCentersRepo.Delete(cur, entity.COST_CENTER_ID);
            return(true);
        }