public async Task <IActionResult> ProjectPut(Guid?Id) { var apiMsg = await ApiMessage.Wrap(async() => { var dataJsonStr = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync(); //var dataJson = JsonConvert.SerializeObject(dataJsonStr); var hasProject = await dbClient.Queryable <Project>().AnyAsync(x => x.Id == Id); if (!hasProject) { var userIdString = HttpContext.Session.GetString(UserAuthBusiness.UserAuthFrontendKey); var userId = Guid.Parse(userIdString); var userInfo = await userAuthBusiness.GetUser(userId); InitProject(Id.Value, userInfo); } else { var projectInfo = await dbClient.Queryable <Project>().FirstAsync(x => x.Id == Id); projectInfo.Thumbnail = "//scratchasset.pagetechs.com/thumb/" + Id + ".jpg"; projectInfo.Data = dataJsonStr; await dbClient.Updateable <Project>(projectInfo).ExecuteCommandAsync(); } }); return(Json(apiMsg)); }
public async Task <IActionResult> ChatList(string accessToken) { try { var userIdDocument = await distributedCache.GetValue <string>(accessToken); Guid userId; var apiMsg = new ApiMessage(); if (userIdDocument.ExpireTime < DateTime.Now) { apiMsg.SetFault("AccessToken Timeout"); apiMsg.ErrorCode = "503"; } else if (Guid.TryParse(userIdDocument.Value, out userId)) { apiMsg = await ApiMessage.Wrap(async() => { return(await chatBusiness.GetChatList(userId)); }); } else { apiMsg.SetFault("Invalid accesstoken "); apiMsg.ErrorCode = "503"; } return(Json(apiMsg)); } catch (Exception exc) { return(Content(exc.Message)); } }
public async Task <IActionResult> CreateUser([FromBody] CaRegisterModel model) { ApiMessage apiMsg; //if (model.InviteOrigin != "LnnInvite") //{ // apiMsg = new ApiMessage(); // apiMsg.SetFault("邀请码不能为空"); //} //else //{ apiMsg = await ApiMessage.Wrap(async() => { var resultTuple = await userAccountBusiness.RegisterUserNamePwd(model); HttpContext.Session.Set (UserAccountBusiness.UserAccountSessionkey, Encoding.UTF8.GetBytes(resultTuple.Item3)); await HttpContext.Session.CommitAsync(); await SetAuth(resultTuple.Item3); return(resultTuple.Item3); }); //} return(Json(apiMsg)); }
public async Task <IActionResult> AddOrUpdate(Guid appHeaderId, Guid appStructId) { var itemList = await dbContext.AppStructItem .Where(x => x.AppHeaderId == appHeaderId && x.AppStructId == appStructId) .ToListAsync(); var tmp = DataExtension.StrucItemToModelType(itemList); tmp.Add(new ModelInfo { PropName = "hide", Name = "_id" }); ViewData["ModelType"] = tmp; var appHeaderIdStr = appHeaderId.ToString(); var appStructIdStr = appStructId.ToString(); var entityData = HttpContext.Request.Form.GetBson(); var entity = HttpContext.Request.Form.GetJson(); var id = entity["_id"]?.ToString(); var apiMsg = await ApiMessage.Wrap(async() => { var collection = mongo.GetDatabase(appHeaderIdStr).GetCollection <BsonDocument>(appStructIdStr); if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString()) { await collection.InsertOneAsync(entityData); } else { await collection.FindOneAndUpdateAsync(filter: new BsonDocument("_id", ObjectId.Parse(id)), update: entityData); } }); return(Json(apiMsg)); }
public async Task <IActionResult> GetUserSocialInfo(Guid?connectorUserId) { var userIdStr = User.Claims?.FirstOrDefault(x => x.Type == "OryxUser")?.Value; Guid?owerUserId; if (!string.IsNullOrEmpty(userIdStr)) { owerUserId = Guid.Parse(userIdStr); } else { owerUserId = null; } var apiMsg = await ApiMessage.Wrap(async() => { var userInfo = await userAccountBusiness.GetUserInfo(connectorUserId.Value); var isSubcrib = await userSocialRelationshipBusiness.CheckSubscib(owerUserId, connectorUserId.Value); return(new { userInfo, isSubcrib }); }); return(Json(apiMsg)); }
public async Task <ApiMessage> CreateFile(FileEntry fileEntry) { return(await ApiMessage.Wrap(async() => { await FileAccessor.Add(fileEntry); })); }
public async Task <ApiMessage> CreateCategory(Categories category) { return(await ApiMessage.Wrap(async() => { category.Id = Guid.NewGuid(); category.CreateTime = DateTime.Now; if (category.Tags != null) { for (int i = 0; i < category.Tags.Count; i++) { var item = category.Tags[i]; var dbTag = await CategoryAccessor.OneAsync <Tags>(x => x.Name == item.Name); if (dbTag != null) { category.Tags[i] = dbTag; } else { item.Id = Guid.NewGuid(); item.CreateTime = DateTime.Now; item.CategoryId = category.Id; } } } await CategoryAccessor.Add(category); })); }
public async Task <IActionResult> GetBanners() { var apiMsg = await ApiMessage.Wrap(async() => { var topNews = await contentBusiness.GetLatestNews(); var topPostEntry = await postEntryBusiness.GetHotPostEntry(); var bannerList = await bannersBusienss.GetList() ?? new List <Banners>(); if (topNews != null) { bannerList.Add(new Banners { CreateTime = topNews.CreateTime, Image = topNews.MediaResource?[0]?.ActualPath, Link = "news:" + topNews.Id, Title = topNews.Title }); } if (topPostEntry != null) { bannerList.Add(new Banners { CreateTime = topPostEntry.CreateTime, Image = topPostEntry.PostEntryFileList?[0]?.ActualPath, Link = "postentry:" + topPostEntry.Id, Title = topPostEntry.TextContent }); } return(bannerList); }); return(Json(apiMsg)); }
public async Task <ApiMessage> GetCategoryByParentId(Guid Id, int skipCount = 0, int pageSize = 20) { return(await ApiMessage.Wrap(async() => { return await CategoryAccessor.ListAsync <Categories>(x => x.Status != ContentStatus.Close && x.ParentCategory.Id == Id, skipCount, pageSize); })); }
public async Task <IActionResult> UpdateInfo([FromBody] UpdateUserInfoViewModel udpateModel) { var userIdStr = User.Claims?.FirstOrDefault(x => x.Type == "OryxUser")?.Value; var userId = Guid.Parse(userIdStr); var apiMsg = await ApiMessage.Wrap(async() => await userAccountBusiness.UpdateUserInfo(userId, udpateModel)); return(Json(apiMsg)); }
public async Task <IActionResult> DetailInfo() { var userIdStr = User.Claims?.FirstOrDefault(x => x.Type == "OryxUser")?.Value; var userId = Guid.Parse(userIdStr); var apiMsg = await ApiMessage.Wrap(async() => await userAccountBusiness.GetUserInfo(userId)); return(Json(apiMsg)); }
public async Task <IActionResult> ApiLogout() { var apiMsg = await ApiMessage.Wrap(async() => { }); return(Json(apiMsg)); }
public async Task <IActionResult> Delete(Guid Id) { var apiMsg = await ApiMessage.Wrap(async() => { }); return(Json(apiMsg)); }
public async Task <ApiMessage> CreateContent(ContentEntry content) { return(await ApiMessage.Wrap(async() => { content.CreateTime = DateTime.Now; await ContentAccessor.AddOrUpdate(content); })); }
public async Task <IActionResult> GetPostEntryComments(Guid postEntryId, int skipCount = 0, int pageSize = 0) { var apiMsg = await ApiMessage.Wrap(async() => { return(await postEntryBusiness.GetPostEntryComments(postEntryId, skipCount, pageSize)); }); return(Json(apiMsg)); }
public async Task <IActionResult> PostEntryDetail(Guid Id) { var apiMsg = await ApiMessage.Wrap(async() => { return(await postEntryBusiness.GetPostEntryDetail(Id)); }); return(Json(apiMsg)); }
public async Task <IActionResult> DeleteRole(Guid roleId) { var apiMsg = await ApiMessage.Wrap(async() => { await userAccountBusiness.DeleteRole(roleId); }); return(Json(apiMsg)); }
public async Task <IActionResult> Delete(Guid Id) { var apiMsg = await ApiMessage.Wrap(async() => { await contentBusiness.DeleteContent(Id); }); return(Json(apiMsg)); }
public async Task <IActionResult> SetCloseCategory(Guid categoryId) { var apiMsg = await ApiMessage.Wrap(async() => { await contentBusiness.SetCategoryStatus(categoryId, ContentStatus.Close); }); return(Json(apiMsg)); }
public async Task <IActionResult> AddContentMediaResource(Guid contentId, List <FileEntry> fileEntryList) { var apiMsg = await ApiMessage.Wrap(async() => { await contentBusiness.AppenContentMediaResource(contentId, fileEntryList); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetNews(int skipCount, int pageSize) { var apiMsg = await ApiMessage.Wrap(async() => { return(await contentBusiness.GetNews(skipCount, pageSize)); }); return(Json(apiMsg)); }
public async Task <IActionResult> Delete(Guid Id) { var apiMsg = await ApiMessage.Wrap(async() => { await dbClient.Deleteable <Project>().Where(x => x.Id == Id).ExecuteCommandAsync(); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetCategoryComment(Guid cateId, int skipCount, int pageSize) { var apiMsg = await ApiMessage.Wrap(async() => { return(await contentBusiness.GetCategoryCommentExtPostEntry(cateId, skipCount, pageSize)); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetRecommand() { var apiMsg = await ApiMessage.Wrap(async() => { return(await contentBusiness.GetRecommandContent()); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetNewsest() { var apiMsg = await ApiMessage.Wrap(async() => { return(await contentBusiness.GetLatestNews()); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetCommentsList(Guid Id, int skipCount = 0, int pageSize = 10) { var apiMsg = await ApiMessage.Wrap(async() => { return(await contentBusiness.GetComments(Id, skipCount, pageSize)); }); return(Json(apiMsg)); }
public async Task <IActionResult> Delete(Guid Id) { var apiMsg = await ApiMessage.Wrap(async() => { await tipEntryBussiness.Delete(Id); }); return(Json(apiMsg)); }
public async Task <IActionResult> PostInfo(Project project) { var apiMsg = await ApiMessage.Wrap(async() => { await dbClient.Updateable(project).ExecuteCommandAsync(); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetNewsDetail(Guid id) { var apiMsg = await ApiMessage.Wrap(async() => { return(await contentBusiness.GetNewsDetail(id)); }); return(Json(apiMsg)); }
public async Task <IActionResult> GetTags() { var apiMsg = await ApiMessage.Wrap(async() => { //contentBusiness.GetCartoonTags(); }); return(Json(apiMsg)); }