public ActionResult CreateByUrlMicrosoftDocsApi(Guid?parentDocumentId, string url) { var targetV = new Models.ViewModels.Documents.CreateByUrlMicrosoftDocsApi.CreateByUrlMicrosoftDocsApi(parentDocumentId, url); var targetW = new Models.ViewModels.Documents.CreateByUrlMicrosoftDocsApi.SelectionWorker(targetV); ViewBag.NodeNameParsingMode = targetW.NodeNameParsingMode; return(View(targetV)); }
public ActionResult CreateByUrlMicrosoftDocsApi(Models.ViewModels.Documents.CreateByUrlMicrosoftDocsApi.CreateByUrlMicrosoftDocsApi targetV) { var targetB = new Models.BusinessModels.PageContentSolver.MicrosoftDocsApi(targetV.Url, targetV.NodeNameParsingMode); bool result; result = targetB.GetPage(); if (!result) { return(HttpNotFound()); } result = targetB.ParsePage(); if (!result) { return(HttpNotFound()); } var target = targetB.GetReturn(); var db = new Models.Domains.Entities.DMsDbContext(); target.ParentDocumentId = targetV.ParentDocumentId; if (string.IsNullOrEmpty(targetV.NodeNameParsingMode)) { target.NodeName = targetV.NodeName; } { target.Priority = db.Documents.Where(c => c.ParentDocumentId == targetV.ParentDocumentId).Max(c => c.Priority) + 1; if (target.Priority == null) { target.Priority = 1; } } db.Documents.Add(target); db.SaveChanges(); return(RedirectToAction("Details", new { id = target.DocumentId })); }