public void CreateUserPhotoAction(int?userId, int photoId, UserPhotoActionType actionType, bool preventDuplicate) { if (preventDuplicate && userId != null && HasUserPhotoAction((int)userId, photoId, actionType)) { return; } var userPhotoAction = new UserPhotoActionModel { UserId = userId, PhotoId = photoId, ActionType = actionType }; UserPhotoActions.Add(userPhotoAction); SaveChanges(); }
public int FindUserPhotoActionsCountByType(int photoId, UserPhotoActionType actionType) { return(UserPhotoActions.Count(upa => upa.PhotoId == photoId && upa.ActionType == actionType)); }
public bool HasUserPhotoAction(int userId, int photoId, UserPhotoActionType actionType) { return(UserPhotoActions.Any(upa => upa.UserId == userId && upa.PhotoId == photoId && upa.ActionType == actionType)); }
public List <UserModel> FindUserPhotoActionsByType(int photoId, UserPhotoActionType actionType) { return(UserPhotoActions.Where(upa => upa.PhotoId == photoId && upa.ActionType == actionType).Select(upa => upa.User).ToList()); }