public async Task <ActionResult> IRRDefinition(string id) { var lContext = new IRRContext(); // XXX WORK HERE // Find the post with the given identifier var irrDefinition = await lContext.IRRDefinitions.Find(x => x.Id == new ObjectId(id)).SingleOrDefaultAsync(); if (irrDefinition == null) { return(RedirectToAction("Index")); } var model = new IRRDefinitionModel { IRRDefinition = irrDefinition, }; return(View(model)); }
public async Task <ActionResult> NewFlow(NewFlowModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Flows")); } var lContext = new IRRContext(); var lflow = new Flow { Date = model.Date, Allocation = model.Allocation, Direction = model.Direction, Type = model.Type, Value = model.Value }; await lContext.Flows.InsertOneAsync(lflow); return(RedirectToAction("Flows")); }
public async Task <ActionResult> Index() { var lContext = new IRRContext(); var filter = new BsonDocument(); var sortIrrDefiniton = Builders <IRRDefinition> .Sort.Descending(p => p.Name); var sortFlows = Builders <Flow> .Sort.Descending(p => p.Date); var lIRRDefinitions = await lContext.IRRDefinitions.Find(filter).Sort(sortIrrDefiniton).ToListAsync(); var lFlowsIRRDefinitions = await lContext.Flows.Find(filter).Sort(sortFlows).ToListAsync(); var model = new IndexModel { IRRDefinitions = lIRRDefinitions, Flows = lFlowsIRRDefinitions }; return(View(model)); }
public async Task <ActionResult> NewAncestor(NewAncestorModel model) { if (!ModelState.IsValid) { return(RedirectToAction("IRRDefinition", new { id = model.IRRDefinitionId })); } var lContext = new IRRContext(); var lIRRDefinitionId = new ObjectId(model.IRRDefinitionId); var irrDefinition = await lContext.IRRDefinitions.Find(x => x.Name == model.AncestorName).SingleOrDefaultAsync(); var AncestorId = irrDefinition.Id; var filterIrrDef = Builders <IRRDefinition> .Filter.Eq(s => s.Id, lIRRDefinitionId); var update = Builders <IRRDefinition> .Update.Push(s => s.Ancestors, AncestorId); await lContext.IRRDefinitions.UpdateOneAsync(filterIrrDef, update); return(RedirectToAction("IRRDefinition", new { id = model.IRRDefinitionId })); }
public async Task <ActionResult> NewAllocation(NewAllocationModel model) { if (!ModelState.IsValid) { return(RedirectToAction("IRRDefinition", new { id = model.IRRDefinitionId })); } var blogContext = new IRRContext(); // XXX WORK HERE // add a comment to the post identified by model.PostId. // you can get the author from "this.User.Identity.Name" var lIRRDefinitionId = new ObjectId(model.IRRDefinitionId); var lAllocation = new Allocation { Name = model.Name, Description = model.Description }; var filterIrrDef = Builders <IRRDefinition> .Filter.Eq(s => s.Id, lIRRDefinitionId); var update = Builders <IRRDefinition> .Update.Push(s => s.Allocations, lAllocation); await blogContext.IRRDefinitions.UpdateOneAsync(filterIrrDef, update); return(RedirectToAction("IRRDefinition", new { id = model.IRRDefinitionId })); }