예제 #1
0
        public async Task <IActionResult> Edit(TableWeightLogViewModel weightLogViewModel)
        {
            var user = await _applicationUserService.GetUserByName(this.User.Identity.Name);

            if (user.MeasureType == Enums.MeasureType.lbs)
            {
                weightLogViewModel.WeightValue = WeightConverter.ConvertToKg(_mapper.Map <WeightLog>(weightLogViewModel)).WeightValue;
            }

            await _weigtLogManageService.UpdateWeightLog(weightLogViewModel);

            return(RedirectToAction(nameof(TableController.Index), "Table"));
        }
예제 #2
0
        public Task UpdateWeightLog(TableWeightLogViewModel weightLogViewModel)
        {
            return(Task.Run(() =>
            {
                WeightLog weightLog = _context.WeightLogs.Find(weightLogViewModel.Id);

                weightLog.WeightValue = weightLogViewModel.WeightValue;

                _context.Update(weightLog);

                return _context.SaveChangesAsync();
            }));
        }