public void AdjustPrice(AdjustPrice adjustPrice) { var adjustment = new PriceAdjustment(adjustPrice, Price); Adjustments.Add(adjustment); Price = adjustPrice.NewPrice; }
internal void AdjustPrice(AdjustPrice adjustPrice) { var adjustment = new PriceAdjustment(adjustPrice, Price); Adjustments.Add(adjustment); Price = adjustment.NewPrice; }
public ActionResult AdjustPriceUsingModification(string id, AdjustPrice adjustPrice) { var rental = GetRental(id); var adjustment = new PriceAdjustment(adjustPrice, rental.Price); var modificationupdate = Builders <Rental> .Update .Push(r => r.Adjustments, adjustment) .Set(r => r.Price, adjustPrice.NewPrice); Context.Rentals.UpdateOne(r => r.Id == id, modificationupdate); return(RedirectToAction("Index")); }
public ActionResult AdjustPriceUsingModification(string id, AdjustPrice adjustPrice) { var rental = GetRental(id); var adjustment = new PriceAdjustment(adjustPrice, rental.Price); var modificationUpdate = Update <Rental> .Push(r => r.Adjustments, adjustment) .Set(r => r.Price, adjustPrice.NewPrice); Context.Rentals.Update(Query.EQ("_id", new ObjectId(id)), modificationUpdate); return(RedirectToAction("Index")); }
public async Task<ActionResult> AdjustPrice_RemoveThisBitToMakeMeActive(string id, AdjustPrice adjustPrice) { var rental = await GetRental(id); var adjustment = new PriceAdjustment(adjustPrice, rental.Price); var filter = Builders<Rental>.Filter.Eq(r => r.Id, id); var update = Builders<Rental> .Update .Push(r => r.Adjustments, adjustment) .Set(r => r.Price, adjustPrice.NewPrice); await Context.Rentals.UpdateOneAsync(filter, update); return RedirectToAction("Index"); }