public System.Web.Mvc.ActionResult SaveDocument(EditDocumentModel model) { string strErrorMessage = string.Empty; long nDocID = 0; Document doc = new Document(); doc.DateModified = DateTime.Now; doc.IsCompleted = model.IsCompleted; doc.OriginalDocumentContent = model.OriginalContent; doc.SimplifiedContent = model.SimplifiedContent; doc.Title = model.Title; doc.AuthorId = model.User.AccountId;//model.CarerID == 0 ? model.User.AccountId : model.CarerID; doc.UserId = model.User.AccountId; doc.Id = model.DocumentID; doc.IsFavourite = model.IsFavourite; doc.Summary = model.Summary; doc.Id = model.DocumentID; string result = OBSDataSource.SaveDocument(doc, out nDocID); if (string.IsNullOrEmpty(result)) { //model. += UserLogging.LogUserAction(UserOperations.SaveDocument, model.User, LoggingOperationLevel.Level1, new object[] { doc.Id }, false); //UserLogging.LogUserAction(model. UserLogging.LogUserAction(model.UserActionsLog); UserLogging.LogUserAction(UserOperations.SaveDocument, model.User, LoggingOperationLevel.Level1, new object[] { doc.Id }); return RedirectToAction("List", "Documents"); } else { ViewBag.IsUnSaved = true; ModelState.AddModelError("Model", result); return View("EditDocument", model); } }
public System.Web.Mvc.ActionResult NewDocument(long UserID = 0) { if (HttpContext.Items["loggedOut"] != null && (bool)HttpContext.Items["loggedOut"]) { return RedirectToAction("Home", "Master"); } ViewBag.IsUnSaved = "false"; string strErrorMessage = string.Empty; EditDocumentModel model = new EditDocumentModel(); AccountInfo user = CurrentUser.Details(User.Identity.Name); model.Role = user.Role; model.IsNewDocument = true; if (model.Role == AccountRoles.User) { model.CarerID = user.CarerId; } else if (model.Role == AccountRoles.Carer) { model.ReceiverID = UserID; } return View("EditDocument", model); }
public System.Web.Mvc.ActionResult NewDocument(EditDocumentModel model) { string strErrorMessage = string.Empty; if (ModelState.IsValid) { ModelState.Clear(); model.IsNewDocument = false; OriginalUserDocument newDocument = new OriginalUserDocument(); Document simpDocument = new Document(); if (model.User.Role == AccountRoles.User) { simpDocument.AuthorId = model.User.AccountId; simpDocument.UserId = model.User.AccountId; } else if (model.User.Role == AccountRoles.Carer) { simpDocument.AuthorId = model.User.AccountId; simpDocument.UserId = model.ReceiverID; } if (!string.IsNullOrEmpty(model.Content)) { newDocument.Text = model.Content; newDocument.Type = OriginalDocumentType.odtString; } else if (!string.IsNullOrEmpty(model.URL)) { newDocument.Url = model.URL; newDocument.Type = OriginalDocumentType.odtUrl; } else if (model.FileForConvert.HasTextMIME() && model.FileForConvert.HasTextFile()) { newDocument.FileName = model.FileForConvert.FileName; newDocument.FileContent = model.FileForConvert.GetContent(); newDocument.Type = OriginalDocumentType.odtFile; } string result = String.Empty; if (String.IsNullOrEmpty(model.Content) && String.IsNullOrEmpty(model.URL) && (!model.FileForConvert.HasTextMIME() || !model.FileForConvert.HasTextFile())) { result = ClientDefault.EditDocument_NoTextInput; } else { if (model.User.Role == AccountRoles.User) { result = OBSDataSource.SimplifyDocument(model.User.AccountId, newDocument, out simpDocument); } else if (model.User.Role == AccountRoles.Carer) { result = OBSDataSource.SimplifyCarerDocument(model.ReceiverID, newDocument, out simpDocument); } } if (string.IsNullOrEmpty(result)) { model.OriginalContent = simpDocument.OriginalDocumentContent; model.SimplifiedContent = simpDocument.SimplifiedContent; model.DocumentID = simpDocument.Id; model.Summary = simpDocument.Summary; AccountInfo currentUser = CurrentUser.Details(User.Identity.Name); model.UserActionsLog = UserLogging.LogUserAction(UserOperations.OpenDocument, currentUser, LoggingOperationLevel.Level1, new object[] { model.DocumentID }, false); if (model.User.Role == AccountRoles.Carer) { DocumentReviewModel reviewModel = new DocumentReviewModel(simpDocument); return View("DocumentReview", reviewModel); } } else { ModelState.AddModelError("Model", result); model.IsNewDocument = true; View("EditDocument", model); } } ViewBag.IsUnSaved = "true"; return View("EditDocument", model); }
public System.Web.Mvc.ActionResult Edit(long nDocID) { ViewBag.IsUnSaved = false; string strErrorMessage = string.Empty; EditDocumentModel model = new EditDocumentModel(nDocID); if (!string.IsNullOrEmpty(model.Error)) { ModelState.AddModelError("Model", model.Error); return View("EditDocument", model); } else { AccountInfo user = CurrentUser.Details(User.Identity.Name); model.Role = user.Role; model.IsNewDocument = false; model.CarerID = user.CarerId; model.UserActionsLog = UserLogging.LogUserAction(UserOperations.OpenDocument, user, LoggingOperationLevel.Level1, new object[] { nDocID }, false); } return View("EditDocument", model); }