public ActionResult _Create(int CalculationId, int DocTypeId) //Id ==>Calculation Id
        {
            CalculationLineLedgerAccountViewModel vm = new CalculationLineLedgerAccountViewModel();

            vm.CalculationId = CalculationId;
            vm.DocTypeId     = DocTypeId;
            return(PartialView("_Create", vm));
        }
        public ActionResult DeletePost(CalculationLineLedgerAccountViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            CalculationLineLedgerAccount CalculationLineLedgerAccount = _CalculationLineLedgerAccountService.Find(vm.CalculationLineLedgerAccountId);

            _CalculationLineLedgerAccountService.Delete(CalculationLineLedgerAccount);

            LogList.Add(new LogTypeViewModel
            {
                ExObj = CalculationLineLedgerAccount,
            });
            XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                ModelState.AddModelError("", message);
                return(PartialView("_Create", vm));
            }

            //LogActivity.LogActivityDetail(new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.CalculationLedgerAccount).DocumentTypeId,
            //     CalculationLineLedgerAccount.CalculationLineLedgerAccountId,
            //     null,
            //     (int)ActivityTypeContants.Deleted,
            //     "",
            //     User.Identity.Name,
            //     "", Modifications);


            LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.CalculationLedgerAccount).DocumentTypeId,
                DocId           = CalculationLineLedgerAccount.CalculationLineLedgerAccountId,
                ActivityType    = (int)ActivityTypeContants.Deleted,
                UserRemark      = "",
                xEModifications = Modifications,
            }));

            return(Json(new { success = true }));
        }
        public ActionResult _Edit(int?CLineLedgerId, int DocTypeId, int CalculationProductId, int CalculationId)
        {
            if (CLineLedgerId.HasValue && CLineLedgerId > 0)
            {
                CalculationLineLedgerAccountViewModel temp = _CalculationLineLedgerAccountService.GetCalculationLineLedgerAccount(CLineLedgerId.Value);

                if (temp == null)
                {
                    return(HttpNotFound());
                }
                return(PartialView("_Create", temp));
            }
            else
            {
                CalculationLineLedgerAccountViewModel vm = new CalculationLineLedgerAccountViewModel();
                vm.DocTypeId            = DocTypeId;
                vm.CalculationProductId = CalculationProductId;
                vm.CalculationId        = CalculationId;
                return(PartialView("_Create", vm));
            }
        }
        public ActionResult _CreatePost(CalculationLineLedgerAccountViewModel svm)
        {
            CalculationLineLedgerAccount s = Mapper.Map <CalculationLineLedgerAccountViewModel, CalculationLineLedgerAccount>(svm);

            if (ModelState.IsValid)
            {
                if (svm.CalculationLineLedgerAccountId <= 0)
                {
                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    s.SiteId       = (int)System.Web.HttpContext.Current.Session["SiteId"];
                    s.DivisionId   = (int)System.Web.HttpContext.Current.Session["DivisionId"];
                    s.ObjectState  = Model.ObjectState.Added;

                    _CalculationLineLedgerAccountService.Create(s);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }
                    return(Json(new { success = true }));
                    //return RedirectToAction("_Create", new { CalculationId = s.CalculationId, DocTypeId=s.DocTypeId });
                }
                else
                {
                    List <LogTypeViewModel>      LogList = new List <LogTypeViewModel>();
                    CalculationLineLedgerAccount temp1   = _CalculationLineLedgerAccountService.Find(svm.CalculationLineLedgerAccountId);


                    CalculationLineLedgerAccount ExRec = Mapper.Map <CalculationLineLedgerAccount>(temp1);

                    temp1.CalculationProductId  = s.CalculationProductId;
                    temp1.CostCenterId          = s.CostCenterId;
                    temp1.LedgerAccountCrId     = s.LedgerAccountCrId;
                    temp1.LedgerAccountDrId     = s.LedgerAccountDrId;
                    temp1.ContraLedgerAccountId = s.ContraLedgerAccountId;

                    temp1.ModifiedDate = DateTime.Now;
                    temp1.ModifiedBy   = User.Identity.Name;
                    temp1.ObjectState  = Model.ObjectState.Modified;
                    _CalculationLineLedgerAccountService.Update(temp1);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp1,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    // LogActivity.LogActivityDetail(new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.CalculationLedgerAccount).DocumentTypeId,
                    //temp1.CalculationLineLedgerAccountId,
                    //null,
                    //(int)ActivityTypeContants.Modified,
                    //"",
                    //User.Identity.Name, "", Modifications);


                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.CalculationLedgerAccount).DocumentTypeId,
                        DocId           = temp1.CalculationLineLedgerAccountId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));



                    return(Json(new { success = true }));
                }
            }
            return(PartialView("_Create", svm));
        }