private float GetPrice(MealCost mealCost) { switch (mealCost) { case MealCost.High: return(_settings.HighFood); case MealCost.Normal: return(_settings.NormalFood); case MealCost.Low: return(_settings.LowFood); default: return(0); } }
// To Update Meal Rate public int AddMealRate(MealCost model) { using (var context = new JustHallAtumationEntities()) { var result = context.MealCosts.FirstOrDefault(); if (result == null) // Meal Cost Not Found Add Meal Cost { MealCost mealCost = new MealCost() { MealCost1 = model.MealCost1 }; context.MealCosts.Add(mealCost); context.SaveChanges(); return(mealCost.MealCostId); } else // OtherWise Update MealCost { result.MealCost1 = model.MealCost1; context.SaveChanges(); return(result.MealCostId); } } }
public ActionResult AddMealRate(MealCost model) { try { if (ModelState.IsValid) { int id = mealManagementOperation.AddMealRate(model); if (id > 0) { ModelState.Clear(); ViewBag.Success = "Meal Rate Added!"; } else { ViewBag.Success = "Meal Rate Not Added!"; } } return(RedirectToAction("ShowMealRate")); } catch (Exception ex) { return(View(ex)); } }
protected void Page_Load(object sender, EventArgs e) { this.lblEmpChargeValue.Visible = false; this.lblEmpCharge.Visible = false; this.lblCurMeals.Visible = false; this.lblCurMealsValue.Visible = false; Location location = (Location)this.Session["location"]; this.lblLocation.Text = "Location: " + location.Description; this.mealCost.find("(CONVERT(datetime, CONVERT(varchar, GETDATE(), 108), 108) BETWEEN CONVERT(datetime, CONVERT(varchar, StartTime, 108), 108) AND CONVERT(datetime, CONVERT(varchar, EndTime, 108), 108)) "); this.mealCostSpec.find("(CafeDoorPriceID = 'doorspec') "); if (this.mealCost.Id == null) { this.mealCost = this.mealCostSpec; if (location.isCafe()) { this.tbID.Visible = false; this.lblError.Visible = true; this.lblError.Text = "Outside normal meal hours"; } } Customer customer = (Customer)this.Session["customer"]; this.MunchChargeOnlySetup(location.isCafe(), customer); this.empMealCost.find("(CONVERT(datetime, CONVERT(varchar, GETDATE(), 108), 108) BETWEEN CONVERT(datetime, CONVERT(varchar, StartTime, 108), 108) AND CONVERT(datetime, CONVERT(varchar, EndTime, 108), 108)) "); this.empMealCostSpec.find("(CafeEmpChargePriceID = 'SPECIAL') "); if (this.empMealCost.Id == null) { this.empMealCost = this.empMealCostSpec; } this.Session["normalAmount"] = this.mealCost.Amout; this.Session["meal"] = this.mealCost.Id; this.Session["specialAmount"] = this.mealCostSpec.Amout; if (this.txtCostPerMeal.Text == "") { this.txtCostPerMeal.Text = ((decimal)this.Session["normalAmount"]).ToString("#,##0.00"); } if (this.empMealCost.Description == null) { this.lblMealValue.Text = this.empMealCostSpec.Description; } else { this.lblMealValue.Text = this.empMealCost.Description; } if (!base.IsPostBack) { string str2 = Roles.GetRolesForUser(HttpContext.Current.User.Identity.Name)[0]; this.dsNavigation.DataFile = "Navigation/" + str2 + ".xml"; } this.tbID.Focus(); }