public JsonResult MakeCupOfCoffeeIfNeeded(string appUserId) { CoffeeDeviceState coffeeDeviceState = GetCurrentUserCoffeeDeviceState(appUserId); if (coffeeDeviceState != null) { if (IsResourcesAmountEnough(coffeeDeviceState)) { bool isCoffeeDone = _coffeeRepository.MakeCupOfCoffeeIfNeeded(appUserId, DateTime.Now); if (isCoffeeDone) { return(new JsonResult(new { message = "ok", coffeDeviceState = GetCurrentUserCoffeeDeviceState(appUserId) })); } else { return(new JsonResult(new { message = "isn't needed", coffeDeviceState = GetCurrentUserCoffeeDeviceState(appUserId) })); } } else { _coffeeRepository.UpdateCoffeSeviceState(appUserId); return(new JsonResult(new { message = "error", coffeDeviceState = GetCurrentUserCoffeeDeviceState(appUserId) })); } } else { return(new JsonResult(new { message = "error" })); } }
public JsonResult MakeCupOfCoffee(RequestCoffeeLog requestCoffeeLog) { CoffeeDeviceState coffeeDeviceState = GetCurrentUserCoffeeDeviceState(requestCoffeeLog.AppUserId); if (coffeeDeviceState != null) { if (IsResourcesAmountEnough(coffeeDeviceState)) { CoffeeLog coffeeLog = RequestCoffeeLogToCoffeeLog(requestCoffeeLog); _coffeeRepository.MakeCupOfCoffee(coffeeLog); return(new JsonResult(new { message = "ok", coffeDeviceState = GetCurrentUserCoffeeDeviceState(requestCoffeeLog.AppUserId) })); } else { _coffeeRepository.UpdateCoffeSeviceState(requestCoffeeLog.AppUserId); return(new JsonResult(new { message = "error", coffeDeviceState = GetCurrentUserCoffeeDeviceState(requestCoffeeLog.AppUserId) })); } } else { return(new JsonResult(new { message = "error", })); } }
protected override void OnAppearing() { CoffeeDeviceState coffeeDevice = Logic.GetCoffeeDeviceState(); Coffee.Value = coffeeDevice.currentCoffeeAmount; Water.Value = coffeeDevice.currentWaterAmount; Milk.Value = coffeeDevice.currentMilkAmount; }
void OnAppearing(object sender, EventArgs args) { CoffeeDeviceState coffeeDevice = Logic.GetCoffeeDeviceState(); Coffee.Value = coffeeDevice.currentCoffeeAmount; Water.Value = coffeeDevice.currentWaterAmount; Milk.Value = coffeeDevice.currentMilkAmount; }
public CoffeeMachineDetails() { InitializeComponent(); CoffeeDeviceState coffeeDevice = Logic.GetCoffeeDeviceState(); Coffee.Value = coffeeDevice.currentCoffeeAmount; Water.Value = coffeeDevice.currentWaterAmount; Milk.Value = coffeeDevice.currentMilkAmount; }
private bool IsResourcesAmountEnough(CoffeeDeviceState coffeeDeviceState) { return(coffeeDeviceState.CurrentWaterAmount > 10 && coffeeDeviceState.CurrentMilkAmount > 10 && coffeeDeviceState.CurrentCoffeeAmount > 5); }