private MeasurementForShopItemModel GetBaseMeasurement(DbShoppingListItemMeasurement m) { var n = BaseMeasurement.GetMeasurement(m.ProductQuantity.UnitQuantityType); n.Barcode = m.ProductQuantity.Barcode; n.ProductQuantityId = m.ProductQuantity.Id; n.UnitQuantityTypeVolume = m.ProductQuantity.QuantityTypeVolume; return(new MeasurementForShopItemModel(n) { Count = m.Count }); }
public async void MeasurementClicked(SelectableMeasurement m) { m.SelectedCount++; double currentAmount = 0f; foreach (var item in MeasurementsOptions.Where(m => m.SelectedCount > 0)) { currentAmount += item.SelectedCount * BaseMeasurement.GetMeasurement(item.Measurement).ConvertTo(MeasurementType); } CurrentSelectedAmount = currentAmount; if (CurrentSelectedAmount >= RequiredAmount) { await OnConfirm.InvokeAsync(this); } }
// Conversions //private List<DbProductQuantity> ConvertProductQuantities(IEnumerable<BaseMeasurement> p, DbProduct product) //{ // var retval = new List<DbProductQuantity>(); // foreach (BaseMeasurement q in p) // { // retval.Add(new DbProductQuantity // { // ProductId = product, // QuantityTypeVolume = q.UnitQuantityTypeVolume, // UnitQuantity = q.Quantity, // UnitQuantityType = q.MeasurementType // }); // } // return retval; //} private List <BaseMeasurement> ConvertProductQuantities(IEnumerable <DbProductQuantity> p) { var retval = new List <BaseMeasurement>(); foreach (DbProductQuantity q in p) { var measurement = BaseMeasurement.GetMeasurement(q.UnitQuantityType); measurement.UnitQuantityTypeVolume = q.QuantityTypeVolume; measurement.ProductQuantityId = q.Id; measurement.Barcode = q.Barcode; retval.Add(measurement // new ProductQuantity //{ // Id = q.Id, // UnitQuantityTypeVolume = q.QuantityTypeVolume, // Quantity = q.UnitQuantity, // UnitQuantityType = q.UnitQuantityType, //} ); } return(retval); }