public void Add(AnFOpeningBalance objAnFOpeningBalance)
        {
            long lastId=_OpeningBalanceRepository.GetLastId();
            objAnFOpeningBalance.Id = lastId;

            _OpeningBalanceRepository.Add(objAnFOpeningBalance);
        }
 public Operation Delete(AnFOpeningBalance objAnFOpeningBalance)
 {
     throw new NotImplementedException();
 }
        public Operation Update(AnFOpeningBalance objviewModelList)
        {
            Operation operation = new Operation { Success = true };
            _OpeningBalanceRepository.Update(objviewModelList);
            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception)
            {

                operation.Success = false;
            }

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

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

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
                objOperation.Message = "Save not successful.";
            }
            return objOperation;
        }
 public void Remove(AnFOpeningBalance objAnFOpeningBalance)
 {
     _OpeningBalanceRepository.Delete(objAnFOpeningBalance);
 }
        public ActionResult Update(List<OpeningBalanceViewModel> viewModelList)
        {
            Operation objOperation = new 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)
                    {
                        AnFOpeningBalance objAnFOpeningBalance = _AnFOpeningBalanceService.GetById(item.Id);
                        if (objAnFOpeningBalance == null)
                        {

                            objAnFOpeningBalance = new AnFOpeningBalance();
                            objAnFOpeningBalance.AnFChartOfAccountId = item.AnFChartOfAccountId;
                            objAnFOpeningBalance.Debit = item.Debit;
                            objAnFOpeningBalance.Credit = item.Credit;
                            objAnFOpeningBalance.IsEditable = true;
                            objAnFOpeningBalance.Status = true;
                            objAnFOpeningBalance.CmnFinancialYearId = financialYearId;
                            objAnFOpeningBalance.CmnCompanyId = companyId;
                            objAnFOpeningBalance.CreatedBy = userID;

                            _AnFOpeningBalanceService.Save(objAnFOpeningBalance);

                        }

                        else
                        {
                            objAnFOpeningBalance.Debit = item.Debit;
                            objAnFOpeningBalance.Credit = item.Credit;
                            _AnFOpeningBalanceService.Update(objAnFOpeningBalance);

                        }
                    }

                }

                objOperation = _AnFOpeningBalanceService.Commit();
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
        public ActionResult MapTransactionalHead(List<AnFTransactionalHeadViewModel> listAnFTransactionalHeadViewModel, int projectId, int companyId = 5, int financialYear = 216245)
        {
            Operation objOperation = new Operation { Success = false };
            if (ModelState.IsValid)
            {
                if (listAnFTransactionalHeadViewModel != null)
                {
                    AnFOpeningBalance objAnFOpeningBalance = null;
                    foreach (var item in listAnFTransactionalHeadViewModel)
                    {
                        if (item.OpeningBalanceId == 0)
                        {
                            objAnFOpeningBalance = new AnFOpeningBalance
                            {
                                CmnCompanyId = companyId,
                                //CmnProjectId = projectId,
                                AnFChartOfAccountId = item.Id,
                                CmnFinancialYearId = financialYear
                            };

                            _AnFOpeningBalanceService.Add(objAnFOpeningBalance);
                            objOperation = _AnFOpeningBalanceService.Commit();

                        }
                        else
                        {
                            objAnFOpeningBalance = _AnFOpeningBalanceService.GetById(item.OpeningBalanceId);
                            if (objAnFOpeningBalance != null)
                            {
                                _AnFOpeningBalanceService.Remove(objAnFOpeningBalance);
                                objOperation = _AnFOpeningBalanceService.Commit();
                            }
                        }
                    }

                }
                else { objOperation.Success = true; }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }