public Operation Update(AnFClosingBalance objviewModelList)
        {
            Operation operation = new Operation { Success = true };
            _anfClosingBalanceRepository.Update(objviewModelList);
            try
            {
                _unitOfWork.Commit();
            }
            catch (Exception)
            {

                operation.Success = false;
            }

            return operation;
        }
        public Operation Save(AnFClosingBalance objviewModelList)
        {
            Operation objOperation = new Operation { Success = true, Message = "Saved successfully." };

            long Id = _anfClosingBalanceRepository.AddEntity(objviewModelList);
            objOperation.OperationId = Id;

            try
            {
                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
                objOperation.Message = "Save not successful.";
            }
            return objOperation;
        }
        public ActionResult Update(List<AnfClosingBlanceViewModel> viewModelList)
        {
            ERPOptima.Lib.Model.Operation objOperation = new ERPOptima.Lib.Model.Operation { Success = false };

            int financialYearId = Convert.ToInt32(Session["financialYear"].ToString());
            int companyId = Convert.ToInt32(Session["companyId"].ToString());
            int userID = Convert.ToInt32(Session["userId"]);

            if (ModelState.IsValid && viewModelList != null)
            {
                foreach (var item in viewModelList)
                {
                    if (item != null)
                    {
                        AnFClosingBalance objAnFClosingBalance = _anfClosingBalanceService.GetById(item.Id);
                        if (objAnFClosingBalance == null)
                        {

                                objAnFClosingBalance = new AnFClosingBalance();
                                objAnFClosingBalance.AnfChartOfAccountId = item.AnFChartOfAccountId;
                                objAnFClosingBalance.Debit = item.Debit;
                                objAnFClosingBalance.Credit = item.Credit;
                                objAnFClosingBalance.IsEditable = true;
                                objAnFClosingBalance.Status = true;
                                objAnFClosingBalance.CmnFinancialYearId = financialYearId;
                                objAnFClosingBalance.CmnCompanyId = companyId;
                                objAnFClosingBalance.CreatedBy = userID;

                                _anfClosingBalanceService.Save(objAnFClosingBalance);

                       }

                       else
                        {
                                objAnFClosingBalance.Debit = item.Debit;
                                objAnFClosingBalance.Credit = item.Credit;
                                _anfClosingBalanceService.Update(objAnFClosingBalance);

                        }
                    }

                }

                objOperation = _anfClosingBalanceService.Commit();
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }