public Domain.CoffeeRoastingEvent Map(CoffeeRoastingEvent dbEvent) { return(new( Id <Domain.CoffeeRoastingEvent> .From(dbEvent.Id), dbEvent.Contacts.Select(c => c.Id).Select(id => Id <Contact> .From(id)), dbEvent.IsActive, LocalDate.FromDateTime(dbEvent.Date), LocalDate.FromDateTime(dbEvent.OrderByDate), Name <Domain.CoffeeRoastingEvent> .Create(dbEvent.Name), dbEvent.CoffeeRoastingEventCoffees.ToDictionary( ec => OrderReferenceLabel.Create(ec.Label), ec => new Coffee( Id <Coffee> .From(ec.Coffee.Id), Name <Coffee> .Create(ec.Coffee.Name), Description.Create(ec.Coffee.Description), UsdPrice.Create(ec.Coffee.Price), Ounces.Create(ec.Coffee.OzWeight))), dbEvent.Orders.Select(order => new Domain.Order( Id <Domain.Order> .From(order.Id), Id <Contact> .From(order.ContactId), OffsetDateTime.FromDateTimeOffset(order.CreatedTimestamp), order.OrderCoffees.ToDictionary( oc => Id <Coffee> .From(oc.CoffeeId), oc => OrderQuantity.Create(oc.Quantity)), new Domain.Invoice( Id <Domain.Invoice> .From(order.Invoice.Id), UsdInvoiceAmount.Create(order.Invoice.Amount), order.Invoice.IsPaid, order.Invoice.PaymentMethod), order.IsConfirmed)))); }
private static void DoClient(TcpClient socket) { using (StreamReader sr = new StreamReader(socket.GetStream())) using (StreamWriter sw = new StreamWriter(socket.GetStream())) { // Ændre disse 4 linijer String incommingStr = sr.ReadLine(); string outstring = ""; string[] strings = incommingStr.Split(" "); if (strings[0] == "toGram") { double rg = double.Parse(strings[1]); Converter C = new Converter(); Ounces O = new Ounces(rg); double convertToGram = C.ConvertToGram(O); outstring = convertToGram.ToString(); } if (strings[0] == "toOunces") { double rg = double.Parse(strings[1]); Converter C = new Converter(); Gram G = new Gram(rg); double convertToOunces = C.ConvertToOunces(G); outstring = convertToOunces.ToString(); } Console.WriteLine($"String in = {outstring}"); sw.WriteLine(outstring); sw.Flush(); // her til } socket?.Close(); }
public Coffee( Id <Coffee> id, Name <Coffee> name, Description description, UsdPrice price, Ounces netWeightPerBag) : base(id) { Name = name; Description = description; Price = price; NetWeightPerBag = netWeightPerBag; }
public void TestMethod1() { Gram G = new Gram(1); Ounces O = new Ounces(1); Converter Converter = new Converter(); double gramToOunces = 0.0352739619; double ouncesToGram = 28.3495231; Assert.AreEqual(gramToOunces, Converter.ConvertToOunces(G)); Assert.AreEqual(ouncesToGram, Converter.ConvertToGram(O)); }
public void Ounces_2_tons() { FloatCompare(3.125e-5f, Ounces.Tons(1)); }
public void Ounces_2_kilograms() { FloatCompare(0.028349524f, Ounces.Kilograms(1)); }
public void Ounces_2_pounds() { FloatCompare(0.0625f, Ounces.Pounds(1)); }
public void Ounces_2_grams() { FloatCompare(28.349523f, Ounces.Grams(1)); }
private void Print() { Console.WriteLine(Formatter.GetString(OriginalValue.ToString(), ORIGINAL_TYPE, nameof(Kilograms), Kilograms.ToString("#.######"))); Console.WriteLine(Formatter.GetString(OriginalValue.ToString(), ORIGINAL_TYPE, nameof(Ounces), Ounces.ToString("#.######"))); Console.WriteLine(Formatter.GetString(OriginalValue.ToString(), ORIGINAL_TYPE, nameof(Stone), Stone.ToString("#.######"))); Console.WriteLine(); }
public async Task <ActionResult <Dto.Coffee> > UpdateCoffee(Guid id, [FromBody] Dto.CoffeePostRequest request, CancellationToken cancellationToken) { var cmd = new UpdateCoffeeCommand { CoffeeId = Id <Coffee> .From(id), Name = request.Name != null ? Name <Coffee> .Create(request.Name) : null, Description = request.Description != null?Description.Create(request.Description) : null, Price = request.PriceInUsd.HasValue ? UsdPrice.Create(request.PriceInUsd.Value) : null, WeightPerBag = request.WeightPerBagInOz.HasValue ? Ounces.Create(request.WeightPerBagInOz.Value) : null, }; var coffee = await _mediator.Send(cmd, cancellationToken); return(Accepted($"/api/v1/coffees/{coffee.Id}", new Dto.Coffee { Id = coffee.Id, Name = coffee.Name, Description = coffee.Description, PriceInUsd = coffee.Price, WeightPerBagInOz = coffee.NetWeightPerBag, })); }