public void Get_Blog() { var blog = BlogService.Get <Blog>(blogId); Assert.IsTrue(blog != null); Assert.AreEqual(blogId, blog.ID); Assert.AreEqual("Test blog", blog.Title); }
private void Get() { _httpForm.Expect(h => h.Get(It.IsAny <string>())).Returns("html snippet").Verifiable(); _converter.Expect(c => c.Convert(It.IsAny <string>(), It.IsAny <string>())).Returns((StoryContent)null).Verifiable(); _contentService.Get("http://weblogs.asp.net/rashid"); }
public string GetFromContentService(string Local, string Virtual, string ApiAttribute = null, Dictionary <string, string> ApiHeaders = null) { ContentService Service = new ContentService(Local, Virtual); if (ApiAttribute != null) { Service.SetApiResourceAttribute(ApiAttribute); } if (ApiHeaders != null) { Service.SetApiResourceHeaders(ApiHeaders); } ServiceResponse Response = Service.Get(); if (VerifyResponse(Service.IsDeviceOnline(), Response.UsesCache)) { System.Diagnostics.Debug.WriteLine("Some content will be used"); } else { System.Diagnostics.Debug.WriteLine("No content will be used"); } System.Diagnostics.Debug.WriteLine(Response.Data); return(Response.Data); }
public async Task <JsonResult> UpdateTask(int id, TaskIn model) { var notify = false; var task = ContentService.Get <TaskItem>(model.Id); if (model.AssignedTo.HasValue && model.AssignedTo != task.AssignedTo && model.AssignedTo != User.Id) { notify = true; } task.Name = model.Name; task.Description = model.Description; task.Completed = model.Completed; task.DueDate = model.DueDate; task.AssignedTo = model.AssignedTo; task.Priority = model.Priority; var updated = ContentService.Update <TaskItem>(task); // notify if (notify) { NotificationService.Insert( new Notification(model.AssignedTo.Value, $@"{User.GetTitle()} assigned you to the task <strong>{task.Name}</strong>") { Link = task } ); } // push realtime event await PushService.Push("task_updated", task); return(Json(updated)); }
private void Get() { _httpForm.Setup(h => h.Get(It.IsAny <HttpFormGetRequest>())).Returns(new HttpFormResponse { Response = "html snippet" }).Verifiable(); _converter.Setup(c => c.Convert(It.IsAny <string>(), It.IsAny <string>())).Returns((StoryContent)null).Verifiable(); _contentService.Get("http://weblogs.asp.net/rashid"); }
public ActionResult Home() { var model = new HomeViewModel { Page = ContentService.Get <Page>("home"), Entries = ContentService.Get <BlogEntry>().ToList() }; return(View(model)); }
public PartialViewResult EditModal(int taskId) { var task = ContentService.Get <TaskItem>(taskId); if (task == null) { ThrowResponseException(HttpStatusCode.NotFound, "Task with id " + taskId + " not found."); } return(PartialView("_EditTask", task)); }
public async Task <JsonResult> ToggleCompleted(int id) { var task = ContentService.Get <TaskItem>(id); task.Completed = !task.Completed; var updated = ContentService.Update <TaskItem>(task); // push realtime event await PushService.Push("task_toggle_completed", task); return(Json(updated)); }
public async Task <ActionResult> Get(ContentType contentType, string key, int seq) { try { var content = await ContentService.Get(contentType, key, seq); return(File(content.Data, content.HttpContentType)); } catch (Exception ex) { return(Helper.HandleException(ex)); } }
public JsonResult ToggleCompleted(int id, int taskId, bool completed) { var app = GetApp(id); var task = ContentService.Get <TaskItem>(taskId); if (task != null) { task.Completed = completed; task = ContentService.Update(task); } // return json return(Json(task)); }
public async Task <JsonResult> DeleteTask(int id) { var task = ContentService.Get <TaskItem>(id); if (task != null) { ContentService.Delete(task.Id); } // push realtime event await PushService.Push("task_deleted", task); return(Json("Deleted")); }
public ActionResult UpdateSortOrder(int id, IEnumerable <int> ids) { int order = 0; foreach (var i in ids) { var task = ContentService.Get <TaskItem>(i); if (task != null && task.SortOrder != order) { task.SortOrder = order; ContentService.Update(task); } order++; } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ActionResult UpdateSortOrder(int id, IEnumerable <int> ids) { //var app = GetApp(id); int order = 0; foreach (var i in ids) { var task = ContentService.Get <TaskItem>(i); if (task != null) { task.SortOrder = order++; ContentService.Update(task); } } return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
public IEnumerable <string> GetAllImageUrls(Guid contentId) { List <string> images = new List <string>(); IContent content = ContentService.Get(contentId); if (content != null) { LegacyContentIdentifier lContentId = LegacyContentService.GetLegacyIdentification(content); IViewableContent vContent = LegacyContentService.GetViewableContent(contentId); if (vContent != null && lContentId != null) { int applicationId; string[] ids = vContent.Container.UniqueID.Split(new[] { ':' }); if (ids.Length == 2) { if (int.TryParse(ids[1], out applicationId)) { IAttachment attachment = AttachmentService.Get(applicationId, (int)vContent.Container.ApplicationType, 0, lContentId.LegacyId); if (attachment != null) { if (FileViewerService.GetMediaType(attachment.File, FileViewerViewType.Preview, false) == FileViewerMediaType.Image) { images.Add(Globals.FullPath(attachment.Url)); } } } } } //Now does the content contain any images images.AddRange(ParseImagesFromContent(content.HtmlDescription(""))); //Container Image images.Add(Globals.FullPath(content.Application.Container.AvatarUrl)); } return(images.Distinct(StringComparer.OrdinalIgnoreCase)); }
public ContentReadResponse Read(string id) { try { var dbContent = _contentService.Get(id); return(new ContentReadResponse { Content = dbContent.MapToContent() }); } catch (Exception ex) { return(new ContentReadResponse { Success = false, Message = ex.Message }); } }
public ActionResult Update(int taskId) { TaskItem task = ContentService.Get <TaskItem>(taskId); if (task == null) { ThrowResponseException(HttpStatusCode.NotFound, "Task with id " + taskId + " not found."); } // save reference to previously assigned user var assignedTo = task.AssignedTo; TryUpdateModel(task); if (ModelState.IsValid) { // perform some simple text processing for emoji etc. task.Name = task.Name.TweetText(); // extract @mention from text if no assignee was supplied if (task.AssignedTo == null) { var tokens = task.Name.ExtractTokens(); var mention = tokens.FirstOrDefault(t => t.Type == Core.TwitterText.TokenType.Mention); if (mention != null && mention.UserId != null) { task.AssignedTo = mention.UserId; } } // update task task = ContentService.Update(task); // notify assigned user if (task.AssignedTo != null && task.AssignedTo != assignedTo) { NotifyAssignedUser(task); } } return(PartialView("_EditTask", task)); }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { base.OnActionExecuted(filterContext); var result = filterContext.Result as ViewResult; if (result != null && result.Model != null) { if (result.Model is Page) { var model = result.Model as Page; ViewBag.Parents = ContentService .Get <Page>() .Where(p => p.ID != model.ID); } if (result.Model is TextContent) { ViewBag.Files = ContentService.Get <File>(); } } }
public ActionResult Edit(string path = "") { var content = ContentService.Get <Content>(path); return(View(content)); }
public ActionResult Upload() { var files = ContentService.Get <File>(); return(View(files)); }
public FileResult File(string path) { var file = ContentService.Get <File>(path); return(File(file.Data, file.MimeType)); }
public ActionResult Comments(int id) { var task = ContentService.Get <TaskItem>(id); return(PartialView("_TaskComments", task)); }
public ActionResult MainNavigation() { var navPages = ContentService.Get <Page>(); return(PartialView(navPages)); }