public async Task <bool> UpdateUserInfoAsync(UserInfoEntity user) { var oldUserData = await _db.UserInfoEntities.FirstOrDefaultAsync(x => x.UserId == user.UserId); oldUserData.FirstName = user.FirstName; oldUserData.LastName = user.LastName; oldUserData.BirthDate = user.BirthDate; oldUserData.SexType = user.SexType; oldUserData.Description = user.Description; oldUserData.OriginalAvatarUrl = user.OriginalAvatarUrl; oldUserData.CityId = user.CityId; return(await _db.SaveChangesAsync() > 0); }
public async Task <bool> UpdateLastSeen(int userId) { var user = await _context.UserInfoDb.FirstOrDefaultAsync(x => x.UserId == userId); user.LastNotsSeenDate = DateTime.UtcNow; _context.Update(user); return(await _context.SaveChangesAsync() > 0); }
public async Task <bool> UpdateAnswer(AnswerEntity answer) { _context.AnswerEntities.Add(answer); return(await _context.SaveChangesAsync() > 0); //return await _context.Database.ExecuteSqlCommandAsync( // $"updateAnswer {userId}, {questionId}, {answerType}, {answered}") > 0; }
public async Task <bool> UpdateAnswer(TwoButtonsContext context, AnswerEntity answer) { context.AnswerEntities.Add(answer); // var p = context.AnswerEntities.ToList(); // var y = p; return(await context.SaveChangesAsync() > 0); //return await _context.Database.ExecuteSqlCommandAsync( // $"updateAnswer {userId}, {questionId}, {answerType}, {answered}") > 0; }
public async Task <bool> Follow(int userId, int followingUserId) { var relation = await _db.UserRelationshipEntities.FirstOrDefaultAsync( x => x.UserId == userId && x.FollowingId == followingUserId); if (relation == null) { relation = new FollowingEntity { UserId = userId, FollowingId = followingUserId, VisitsCount = 0, IsFollowing = true, FollowingDate = DateTime.UtcNow, LastVisitDate = DateTime.UtcNow }; _db.UserRelationshipEntities.Add(relation); } relation.IsFollowing = true; return(await _db.SaveChangesAsync() > 0); }
public async Task <bool> UpdateQuestionFeedback(int userId, int questionId, QuestionFeedbackType feedback) { var answer = await _db.AnswerEntities.FirstOrDefaultAsync(x => x.UserId == userId && x.QuestionId == questionId); if (answer == null) { answer = new AnswerEntity { UserId = userId, QuestionId = questionId, FeedbackType = feedback, IsDeleted = false, AnswerType = AnswerType.NoAnswer, AnsweredDate = DateTime.UtcNow, IsFavorite = false, IsSaved = false }; _db.AnswerEntities.Add(answer); return(await _db.SaveChangesAsync() > 0); } answer.FeedbackType = feedback; return(await _db.SaveChangesAsync() > 0); }
public async Task <bool> UpdateUserInfoAsync(UserInfoEntity user) { var userChanged = await _contextMain.UserInfoEntities.FirstOrDefaultAsync(x => x.UserId == user.UserId); if (userChanged == null) { return(false); } userChanged.FirstName = user.FirstName; userChanged.LastName = user.LastName; userChanged.BirthDate = user.BirthDate; userChanged.SexType = user.SexType; userChanged.Description = user.Description; userChanged.OriginalAvatarUrl = user.OriginalAvatarUrl; return (await _contextMain.SaveChangesAsync() > 0); //_contextMain.Database.ExecuteSqlCommandAsync( $"updateUserTableData {user.UserId}, {user.Login}, {user.BirthDate}, {user.SexType}, {user.City}, {user.Description}, {user.OriginalAvatarUrl}") > 0; }
public async Task <bool> AddFeedbackAsync(FeedbackEntity feedback) { _db.FeedbackEntities.Add(feedback); return(await _db.SaveChangesAsync() > 0); }
public async Task <bool> AddTags(IEnumerable <TagEntity> tags) { _db.TagEntities.AddRange(tags); return(await _db.SaveChangesAsync() > 0); }
public async Task <bool> AddUserMonitoring(UrlMonitoringDb userMonitoring) { _db.UrlMonitoringsDb.Add(userMonitoring); return(await _db.SaveChangesAsync() > 0); }
public async Task <bool> AddCityAsync(CityEntity city) { _db.CityEntities.Add(city); return(await _db.SaveChangesAsync() > 0); }