public ActionResult HeaderPost(ReportHeaderViewModel pt)
        {
            if (ModelState.IsValid)
            {
                if (pt.ReportHeaderId <= 0)
                {
                    try
                    {
                        _ReportHeaderService.Create(pt, User.Identity.Name);
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    return(RedirectToAction("Edit", new { id = pt.ReportHeaderId }).Success("Data saved successfully"));
                }
                else
                {
                    try
                    {
                        _ReportHeaderService.Update(pt);
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            return(View("Create", pt));
        }
        public ActionResult HeaderPost(ReportHeader pt)
        {
            if (ModelState.IsValid)
            {
                if (pt.ReportHeaderId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _ReportHeaderService.Create(pt);
                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(TransactionDoctypeConstants.Report).DocumentTypeId,
                        DocId        = pt.ReportHeaderId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Edit", new { id = pt.ReportHeaderId }).Success("Data saved successfully"));
                }
                else
                {
                    pt.ModifiedDate = DateTime.Now;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Modified;
                    _ReportHeaderService.Update(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(TransactionDoctypeConstants.Report).DocumentTypeId,
                        DocId        = pt.ReportHeaderId,
                        ActivityType = (int)ActivityTypeContants.Modified,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            return(View("Create", pt));
        }