Esempio n. 1
0
        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()));
            }
        }
Esempio n. 2
0
        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 } }));
            }
        }
Esempio n. 3
0
        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)));
            }
        }
Esempio n. 4
0
        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)));
            }
        }
Esempio n. 5
0
        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)));
            }
        }
Esempio n. 6
0
        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)));
            }
        }
Esempio n. 7
0
        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));
            }
        }
Esempio n. 8
0
        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)));
            }
        }
Esempio n. 9
0
        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)));
            }
        }
Esempio n. 10
0
        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)));
            }
        }
Esempio n. 11
0
        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()));
            }
        }
Esempio n. 12
0
        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()));
            }
        }