public ActionResult _CreatePost(ReportLineViewModel pt) { if (ModelState.IsValid) { if (pt.ReportLineId <= 0) { try { _ReportLineService.Create(pt, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", pt)); } return(RedirectToAction("_Create", new { id = pt.ReportHeaderId })); } else { try { _ReportLineService.Update(pt, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", pt)); } return(Json(new { success = true })); } } return(PartialView("_Create", pt)); }
public ActionResult _CreatePost(ReportLine pt) { if (ModelState.IsValid) { if (pt.ReportLineId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _ReportLineService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.Report).DocumentTypeId, DocId = pt.ReportHeaderId, DocLineId = pt.ReportLineId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("_Create", new { id = pt.ReportHeaderId })); } else { pt.ModifiedDate = DateTime.Now; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Modified; _ReportLineService.Update(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.Report).DocumentTypeId, DocId = pt.ReportHeaderId, DocLineId = pt.ReportLineId, ActivityType = (int)ActivityTypeContants.Modified, })); return(Json(new { success = true })); } } return(PartialView("_Create", pt)); }