public async Task <IActionResult> Edit(Guid id) { WeightLog weightLog = await _weigtLogManageService.FindWeightLogById(id); var user = await _applicationUserService.GetUserByName(this.User.Identity.Name); ViewBag.MeasureType = user.MeasureType; if (user.MeasureType == Enums.MeasureType.lbs) { weightLog = WeightConverter.ConvertToLbs(weightLog); } WeightLogViewModel weightLogViewModel = _mapper.Map <WeightLogViewModel>(weightLog); return(View(weightLogViewModel)); }
public async Task <IActionResult> OnGet(Guid id) { var log = await _weigtLogService.FindWeightLogById(id); var user = await GetUser(); MeasureType = user.MeasureType; if (user.MeasureType == MeasureType.lbs) { log = WeightConverter.ConvertToLbs(log); } Input = _mapper.Map <WeightLogViewModel>(log); return(Page()); }
public async Task <IActionResult> OnGetAsync() { ApplicationUser user = await _applicationUserService.GetUserByName(User.Identity.Name); var logs = await _weigtLogManageService.GetAllWeightLogs(user); MeasureType = user.MeasureType; if (MeasureType == MeasureType.lbs) { logs = logs.Select(log => log = WeightConverter.ConvertToLbs(log)); } WeightLogs = _mapper.Map <IEnumerable <WeightLogTableViewModel> >(logs); return(Page()); }
public async Task <IActionResult> Index() { IEnumerable <WeightLog> weightLogs = await _weigtLogService.GetAllWeightLogs(await _applicationUserService.GetUserByName(this.User.Identity.Name)); ViewBag.Title = "Data since starting weight"; ApplicationUser user = await _applicationUserService.GetUserByName(User.Identity.Name); ViewBag.MeasureType = user.MeasureType; if (user.MeasureType == Enums.MeasureType.lbs) { weightLogs = weightLogs.Select(log => WeightConverter.ConvertToLbs(log)); } IList <WeightLogViewModel> chartData = _mapper.Map <IEnumerable <WeightLogViewModel> >(weightLogs).ToList(); ViewBag.WeightLogs = chartData.OrderBy(log => log.LogDate); return(View()); }
public async Task <IActionResult> Index() { ApplicationUser user = await _applicationUserService.GetUserByName(this.User.Identity.Name); IEnumerable <TableWeightLogViewModel> tableWeightLogsViewModel = _mapper.Map <IEnumerable <TableWeightLogViewModel> >(await _weigtLogManageService.GetAllWeightLogs(user)); if (user.MeasureType == Enums.MeasureType.lbs) { tableWeightLogsViewModel = tableWeightLogsViewModel.Select(log => { var logForConvert = _mapper.Map <WeightLog>(log); log.WeightValue = WeightConverter.ConvertToLbs(logForConvert).WeightValue; return(log); }); } return(View(tableWeightLogsViewModel)); }