private InputWeightModel initializeInputWeightModel(DateTime date, UserWeight userWeight, IEnumerable<UserWeight> userWeightHistoryList) { var model = new InputWeightModel(); if (userWeight != null) { model.Weight = userWeight.Weight; } model.Date = date; model.UserWeightHistoryList = userWeightHistoryList; return model; }
public ActionResult Input(InputWeightModel inputWeightModel) { UserWeight userWeight = null; try { userWeight = userWeightBusinessLogic.SaveWeight(userContext.User, inputWeightModel.Weight, inputWeightModel.Date); } catch(InvalidWeightException e) { ModelState.AddModelError("Weight", WeightConstant.ZeroWeightErrorMessage); } var userWeightHistory = userWeightBusinessLogic.GetHistoryList(userContext.User); return View(initializeInputWeightModel(inputWeightModel.Date, userWeight, userWeightHistory)); }