public async Task <bool> Update(CanvasDataRaw canvas) { var builder = Builders <CanvasDataRaw> .Filter; var filter = builder.Eq(s => s._id, canvas._id); var result = await this._bmcCollection.ReplaceOneAsync(filter, canvas); return(result.IsAcknowledged); }
public async Task <bool> Patch(string id, [FromBody] CanvasDataRaw canvas) { var canvasBefore = await _repository.GetById(id); if (canvasBefore.BelongsTo != GetUserId()) { throw new AccessViolationException("You are not allowed to change someone else's canvas."); } canvas._id = new ObjectId(id); canvas.BelongsTo = GetUserId(); return(await _repository.Update(canvas)); }
public async Task <bool> Add(CanvasDataRaw canvas) { try { await this._bmcCollection.InsertOneAsync(canvas); return(true); } catch { return(false); } }
public async Task <bool> Post([FromBody] CanvasDataRaw canvas) { canvas._id = ObjectId.GenerateNewId(); canvas.BelongsTo = GetUserId(); canvas.Channels = new CanvasCategoryRaw(); canvas.CostStructure = new CanvasCategoryRaw(); canvas.CustomerRelationships = new CanvasCategoryRaw(); canvas.CustomerSegments = new CanvasCategoryRaw(); canvas.KeyActivities = new CanvasCategoryRaw(); canvas.KeyPartners = new CanvasCategoryRaw(); canvas.KeyResources = new CanvasCategoryRaw(); canvas.RevenueStreams = new CanvasCategoryRaw(); canvas.ValuePropositions = new CanvasCategoryRaw(); return(await _repository.Add(canvas)); }