public IActionResult Edit(UsersViewModel user) { user.Birthdate = user.DateTimeBirthdate.ToString("D"); usersAndRewardsStorage.UpdateUser(user.ConvertUserToDomainModel()); usersAndRewardsStorage.RewardUser(user.ConvertUserToDomainModel()); return(RedirectToAction(nameof(Index))); }
public IActionResult Edit(int?id) { UsersViewModel userEdit = usersAndRewardsStorage.GetUsersList().FirstOrDefault(td => td.Id == id.Value).ConvertUserToViewModel(); userEdit = usersAndRewardsStorage.ExpandUserRewardsList(userEdit.ConvertUserToDomainModel()).ConvertUserToViewModel(); userEdit.DateTimeBirthdate = Convert.ToDateTime(userEdit.Birthdate); return(View("AddOrEdit", userEdit)); }
public IActionResult Add(UsersViewModel user) { UsersModel newDomaiUser = user.ConvertUserToDomainModel(); newDomaiUser.Id = usersAndRewardsStorage.AddUser(newDomaiUser); usersAndRewardsStorage.RewardUser(newDomaiUser); return(RedirectToAction(nameof(Index))); }