public async Task <ActionResult> New() { await UC.InitializeAsync(this); ViewBag.active_addpage = "active"; return(View()); }
public async Task <ActionResult> Index(string pid, string ptitle, int page = 1, bool inbox = false) { ptitle = ptitle.ToStringFarsi(); await UC.InitializeAsync(this); var limit = 20; var skip = limit * (page - 1); ViewBag.page = page; ViewBag.plimit = limit; ViewBag.RowIndexStart = (page * limit) - limit; ViewBag.pid = pid; ViewBag.ptitle = ptitle; string q = "{aggregate:'pages',pipeline:[{$sort : { '_id' : -1 }},{$skip:" + skip.ToString() + "},{$limit:" + limit.ToString() + "},{$match:{$and:[{'status':{$ne:'حذف شده'}},"; if (!string.IsNullOrWhiteSpace(ptitle) || !string.IsNullOrWhiteSpace(pid)) { if (!string.IsNullOrWhiteSpace(ptitle)) { q += "{title:{$regex:'" + ptitle + "'}},"; } if (!string.IsNullOrWhiteSpace(pid)) { q += "{_id:ObjectId('" + pid + "')},"; } } q = q.Trim(',') + "]}}]}"; var model = await NoSql.Instance.RunCommandAsync <BsonDocument>(q); ViewBag.active_pages = "active"; return(View(model.GetValue("result"))); }
public async Task <ActionResult> Edit(string id) { await UC.InitializeAsync(this); string q = "{aggregate:'pages',pipeline:[{$match:{_id:ObjectId('" + id + "')}},{$limit:1}]}"; var model = await NoSql.Instance.RunCommandAsync <BsonDocument>(q); BsonDocument page = model.GetValue("result")[0].AsBsonDocument; if (page.Contains("openedby") && !string.IsNullOrWhiteSpace(page["openedby"].AsString)) { ViewBag.locker = page["openedby"].AsString; return(View("Locked")); } //var uinfo = await UC.UserInfoAsync(); q = "{update:'pages',updates:[{q:{_id:ObjectId('" + id + "')},u:{$set:{openedby:'" + (ViewBag.ME as BsonDocument)["name"].AsString + "'}}}]}"; //await NoSql.Instance.RunCommandAsync<BsonDocument>(q); ViewBag.active_pages = "active"; return(View(page)); }