public async Task <User> SetUserPassword(Guid userGuid, UserPassword userPassword) { var user = await GetUnregisteredUsersByGuidAsync(userGuid); user.Password = GetHashed(userPassword.Password); user.Name = userPassword.Name; user.Surname = userPassword.Surname; _schedulearnContext.Update(user); await _schedulearnContext.SaveChangesAsync(); return(user); }
public async Task <Team> ChangeLimitsForTeamAsync(int teamId, LimitsToApply limits) { var team = await GetTeamAsync(teamId); var wantedLimit = await _limitService.GetLimitAsync(limits.LimitId); team.LimitId = wantedLimit.Id; _schedulearnContext.Update(team); await _schedulearnContext.SaveChangesAsync(); return(team); }
public async Task <Topic> UpdateNameAndDescriptionAsync(int id, ModifiedTopic modifiedTopic) { var topic = await GetTopicAsync(id); topic.Name = modifiedTopic.Name ?? topic.Name; topic.Description = modifiedTopic.Description ?? modifiedTopic.Description; _schedulearnContext.Update(topic); await _schedulearnContext.SaveChangesAsync(); return(topic); }
public async Task <LearningDay> ModifyLearningDayAsync(int id, ModifyLearningDay learningDayToModify) { var learningDay = await _schedulearnContext.LearningDays.FindAsync(id); if (learningDay == null) { throw new NotFoundException(Error_LearningDayNotFound.ReplaceArgs(id)); } if (!learningDayToModify.ForceWrite ?? true) { _schedulearnContext.Entry(learningDay).Property("RowVersion").OriginalValue = learningDayToModify.RowVersion; } learningDay.Description = learningDayToModify.Description; _schedulearnContext.Update(learningDay); await _schedulearnContext.SaveChangesAsync(); return(learningDay); }