public async Task <IActionResult> Create(InviteEditModel model) { if (ModelState.IsValid) { try { PersonView person = await this.personService.GetCurrentPersonViewAsync(); InviteCode code = await this.inviteService.InsertAsync(model, person); return(this.Json(AjaxResult.CreateByContext(code))); } catch (ModelException ex) { return(this.Json(ex.ToAjaxResult())); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } } else { return(this.Json(ModelState.ToAjaxResult())); } }
public async Task <IActionResult> Upload(IFormFile file) { try { UploadInfo info = await this.uploadService.UploadImageAsync(file, false); return(this.Json(AjaxResult.CreateByContext(info.UrlPath))); } catch (Exception e) { return(this.Json(new { uploaded = 0, error = new { message = e.Message } })); } }
public async Task <IActionResult> ChangeStatus([FromBody] Tag tag) { try { Tag newTag = await tagService.ChangeBestStatusAsync(tag, !tag.IsBest); return(this.Json(AjaxResult.CreateByContext(newTag))); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <IActionResult> GetAll() { try { List <Tag> tags = await this.tagService.GetAllAsync(); return(this.Json(AjaxResult.CreateByContext(tags))); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <IActionResult> Search(string search) { try { List <Tag> tags = await this.tagService.SearchAsync(search); return(this.Json(AjaxResult.CreateByContext(tags))); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <IActionResult> GetAll() { try { List <InviteCode> codes = await this.inviteService.GetAllAsync(); return(this.Json(AjaxResult.CreateByContext(codes))); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <IActionResult> GetAll() { try { List <Topic> topics = await this.topicService.GetAllAsync(true, Library.Enums.SearchType.ALL); AjaxResult result = AjaxResult.CreateByContext(topics); return(this.Json(result)); } catch (Exception e) { AjaxResult result = AjaxResult.CreateByMessage(e.Message, false); return(this.Json(result)); } }
public async Task <IActionResult> LikeComment(Guid id) { try { await this.zanService.ZanCommentAsync(id); Comment comment = await this.commentService.GetByIdAsync(id); return(Json(AjaxResult.CreateByContext(comment.LikeNum))); } catch (Exception ex) { return(Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <IActionResult> LikePost(Guid id) { try { await this.zanService.ZanPostAsync(id); Post post = await this.postService.GetPostByIdAsync(id); return(Json(AjaxResult.CreateByContext(post.LikeNum))); } catch (Exception ex) { return(Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <IActionResult> ModifyAvatar(IFormFile file) { try { PersonView person = await this.personService.GetCurrentPersonViewAsync(); UploadInfo info = await this.uploadService.UploadImageAsync(file, true); await this.personService.ModifyAvatarAsync(person, info); return(this.Json(AjaxResult.CreateByContext(info.UrlPath))); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } }
public async Task <ActionResult> Create(TagEditModel model) { if (ModelState.IsValid) { try { Tag tag = await tagService.CreateAsync(model); return(this.Json(AjaxResult.CreateByContext(tag))); } catch (ModelException ex) { return(this.Json(ex.ToAjaxResult())); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } } else { return(this.Json(ModelState.ToAjaxResult())); } }
public async Task <ActionResult> Edit(TopicEditModel model) { if (ModelState.IsValid) { try { Topic topic = await topicService.ModifyAsync(model); return(this.Json(AjaxResult.CreateByContext(topic))); } catch (ModelException ex) { return(this.Json(ex.ToAjaxResult())); } catch (Exception ex) { return(this.Json(AjaxResult.CreateByMessage(ex.Message, false))); } } else { return(this.Json(ModelState.ToAjaxResult())); } }