public ActionResult Edit(string id) { var editData = new EditPostData { EditMode = EditMode.Edit, Post = LoadPost(id), PostCategories = _postCategoryRepository.List(1, int.MaxValue).Items }; return(View("Edit", editData)); }
public ActionResult Add() { var editData = new EditPostData { EditMode = EditMode.Add, Post = _postRepository.Create(), PostCategories = _postCategoryRepository.List(1, int.MaxValue).Items }; return(View("Edit", editData)); }
private async void btnEditPost_Click(object sender, RoutedEventArgs e) { EditPostData postData = new EditPostData(); postData.id = (int)txtGroupId.Value; postData.text = txtPostText.Text; try { var res = await PostAPI.EditPost(postData, AppPersistent.UserToken); if (!res.error) { DialogManager.ShowDialog("S U C C", "Post editing done"); } else { DialogManager.ShowDialog("Not S U C C", res.message); } } catch (Exception ex) { DialogManager.ShowDialog("Some rtarded shit happened", ex.Message); } }
public ActionResult Save( EditMode editMode, string id, string title, string body, bool isPublished, double?latitude, double?longitude, string categoryId, string newCategory, string tags, DateTime?publishDate, DateTime?dateFrom, DateTime?dateTo) { if (String.IsNullOrEmpty(title)) { ModelState.AddModelError("title", "Title must not be empty."); } var post = GetPost(editMode, id); post.Title = title; post.Body = body; post.LastUpdatedTime = DateTime.Now.ToUniversalTime(); post.PublishDate = publishDate; post.IsPublished = isPublished; post.DateFrom = dateFrom; post.DateTo = dateTo; post.Position = latitude != null && longitude != null ? new Position(latitude.Value, longitude.Value) : null; post.Tags.Clear(); foreach (var tag in tags.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { post.Tags.Add(tag); } if (!String.IsNullOrEmpty(newCategory)) { post.Category = CreatePostCategory(post, newCategory); } else { post.Category = GetPostCategory(categoryId); } if (!ModelState.IsValid) { var editData = new EditPostData { EditMode = editMode, Post = post, PostCategories = _postCategoryRepository.List(1, int.MaxValue).Items }; return(View("Edit", editData)); } if (editMode == EditMode.Add) { _postRepository.Save(post); } _postRepository.SubmitChanges(); return(RedirectToAction("Detail", new { id = post.ID })); }