public ServicesResult UpdateDocument(VmDocUpdate vmDocUpdate) { try { var orginalDoc = _document.Find(vmDocUpdate.DocId); if (orginalDoc == null) { return(new ServicesResult() { Success = false, Message = "Document Not Found", }); } var docHistory = new DocHistory() { TypeId = (int)DocHistoryEnumerable.DocHistoryType.EditeDocument, DocId = orginalDoc.DocId, ChangeSet = orginalDoc.Subject + Environment.NewLine + orginalDoc.Content, OwnerUserId = vmDocUpdate.OwnerUserId, OwnerDepartmentId = _chartService.GetDepartment(vmDocUpdate.FolId).ChartId }; orginalDoc.Content = vmDocUpdate.Content; orginalDoc.Subject = vmDocUpdate.Subject; _uow.MarkAsChanged(orginalDoc); _docHistory.Add(docHistory); _uow.SaveChanges(); return(new ServicesResult() { Success = true, Message = "OK", }); } catch (Exception ex) { return(new ServicesResult() { Success = false, Message = ex.Message, InnerExeption = ex.InnerException.Message }); } }
public ActionResult EditDocument(Guid docid) { var model = _documentService.GetDocument(docid); var vmModel = new VmDocUpdate() { DocId = model.DocId, Subject = model.Subject, DocNo = model.DocNo, Content = model.Content, RegisterDateSh = model.RegisterDateSh, }; return(View(vmModel)); }
public ActionResult EditDocument(VmDocUpdate document, Guid folid) { document.FolId = folid; document.OwnerUserId = Guid.Parse(User.Identity.GetUserId()); var result = _documentService.UpdateDocument(document); if (result.Success) { return(RedirectToAction("ShowDocument", new { @docid = document.DocId })); } ModelState.AddModelError("", "اشکال در ویرایش سند"); return(View(document)); }